Circular declarations

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
 
D

David Wilkinson

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.
 
A

Armin Zingler

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top