Circular declarations

  • Thread starter Thread starter Armin Zingler
  • Start date Start date
A

Armin Zingler

Hi,

I'm using VC++ 2008 Express.

I have a managed interface. One of it's member uses a type that is declared
later in the same file. The type implements the interface declared before.
So, I have circular relations between the two declarations.
Question: How do I have to forward-declare the struct? (C++ is still not
clever enough to see the declaration below.)

public interface class IMatrixSource
{
Matrix GetMatrix(); // error: unknown type
};


public value struct Matrix: IMatrixSource
{
public:
//.....
private:
Matrix GetValue() = IMatrixSource::GetValue;
};


If I write "ref struct Matrix;" above the interface declaration, the
compiler says C3816, "'struct Matrix' was previously declared or defined
with a different managed modifier" at the later declaration. What is the
correct syntax?


Armin
 
Armin said:
Hi,

I'm using VC++ 2008 Express.

I have a managed interface. One of it's member uses a type that is declared
later in the same file. The type implements the interface declared before.
So, I have circular relations between the two declarations.
Question: How do I have to forward-declare the struct? (C++ is still not
clever enough to see the declaration below.)

public interface class IMatrixSource
{
Matrix GetMatrix(); // error: unknown type
};


public value struct Matrix: IMatrixSource
{
public:
//.....
private:
Matrix GetValue() = IMatrixSource::GetValue;
};


If I write "ref struct Matrix;" above the interface declaration, the
compiler says C3816, "'struct Matrix' was previously declared or defined
with a different managed modifier" at the later declaration. What is the
correct syntax?

Armin:

If Matrix is a value struct, it might be a good idea to forward declare it as a
value struct.
 
David Wilkinson said:
Armin:

If Matrix is a value struct, it might be a good idea to forward declare it
as a value struct.

OMG, :-/ I *copied* the declaration! Don't know how this could happen.
Thanks, you're right. I'm really ashamed of this; it's so obvious.

Thanks again for your quick reply.


Armin
 
Back
Top