error C2027: use of undefined type

  • Thread starter ramkrishna.kulkarni
  • Start date
R

ramkrishna.kulkarni

Hello,

Please see the code below.

class A : public B<C,D,E>
{
// some data and member variables
}

class P : public Q<R,S>, public T
{
private :
Ref <A> m_typeA;
}

Now, in Ref, I am calling a method on m_typeA to maintain reference
counter. This is where I get an error. I know that the compiler has to
know the class definition before calling some method on it. But you can
see that class A has dependancy on class P. Also, forward declaration
solved the problem on UNIX. However I get " error C2027: use of
undefined type 'A' " on Windows OS.

Please help.

thanks,
- Ram
 
V

Victor Bazarov

Please see the code below.

class A : public B<C,D,E>

Neither of B, C, D, or E, is defined here.
{
// some data and member variables
} ;

class P : public Q<R,S>, public T

Neither Q, nor R, S, or T, are defined here.
{
private :
Ref <A> m_typeA;

Ref is undefined.
;
Now, in Ref, I am calling a method on m_typeA to maintain reference
counter. This is where I get an error. I know that the compiler has to
know the class definition before calling some method on it. But you can
see that class A has dependancy on class P.

Huh? 'A' dependent on 'P'? Where? No, *I* can't see it.
> Also, forward declaration
solved the problem on UNIX. However I get " error C2027: use of
undefined type 'A' " on Windows OS.

Post real code, not ravings of a grey mare.

V
 
C

chhenning

Change the class A declaration to

template < class C, class D, class E >
class A : public B< C, D , E >
{
// some data and member variables

};

Otherwise the compiler doesn't know what C, D, and E is. You also need
to declare B, somewhere.

To define an object of type A you need to give it the types for C, D,
and E. e.g.

A<int, double, long> a;

Greets,
Christian
 

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

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top