error C2027: use of undefined type

Discussion in 'C++' started by ramkrishna.kulkarni@gmail.com, Jul 15, 2005.

  1. Guest

    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
    , Jul 15, 2005
    #1
    1. Advertising

  2. wrote:
    > 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
    Victor Bazarov, Jul 15, 2005
    #2
    1. Advertising

  3. chhenning Guest

    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
    chhenning, Jul 15, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mantorok Redgormor
    Replies:
    70
    Views:
    1,729
    Dan Pop
    Feb 17, 2004
  2. Replies:
    8
    Views:
    545
  3. Anonymous Infidel - Aborted Islam with a hanger

    use of undefined type????

    Anonymous Infidel - Aborted Islam with a hanger, Jun 6, 2007, in forum: C++
    Replies:
    3
    Views:
    717
    Anonymous Infidel - Aborted Islam with a hanger
    Jun 6, 2007
  4. VK
    Replies:
    45
    Views:
    577
    Dr John Stockton
    Sep 12, 2006
  5. -Lost
    Replies:
    13
    Views:
    357
    Richard Cornford
    Jan 31, 2007
Loading...

Share This Page