thetux4
thetux4

Reputation: 1633

Accessing class of class

Class A{
public:
      MyVec<A> test; //problem  error: ‘MyVec’ does not name a type
};

Class B{
public:
      template<typename Obj>
      Class MyVec{
           //some methods...
      };
private:
      MyVec<A> test1; //ok
};

Compiler complains about the line where test is defined.

Upvotes: 1

Views: 84

Answers (2)

Puppy
Puppy

Reputation: 147028

You didn't define or even declare MyVec before the definition of A. This makes it impossible for the type to be used in A. This is because of the order of declarations.

Upvotes: 2

Etienne de Martel
Etienne de Martel

Reputation: 36986

MyVec's full name is B::MyVec. The B:: part is optional when you're inside B.

Upvotes: 1

Related Questions