0

Suppose I have the following header file:

abc_header.h

 class Abc
    {
     public:
       int a;
       int b;
       int c;
    };
    typedef std::vector<Abc> AbcArray;

Then if I want to use this class, I can declare the function that use this class in this way without including the abc_header.h header file:

client1.h

 class Abc;
   void useAbc(Abc &pObj);

Only in the implementation part, the head file will be included. Then I have another function that will use AbcArray class, and in this case it seems that I have to include the abc_header.h header in the function declaration part as the following shows:

client2.h

 #include "abc_header.h"
 void useAbcArray(AbcArray &array);

Any possibility of without including the header file? Thanks.

feelfree
  • 11,175
  • 20
  • 96
  • 167

1 Answers1

3

Just have forward declaration Abc and (!) AbcArray in another header abc_forward_header.h:

class Abc;
typedef std::vector<Abc> AbcArray;