template argument 1 is invalid (Code::Blocks Win Vista) – i don’t use templates

You have a cyclical dependency. Both files need one another to compile.

Try forward-declaring User in group:

#include <vector>
#include <string>

class User;

class Group{
    private :
        std::string name;
        std::string getName(){return name;};
        User *f;
        std::vector<User*> m;
        void show(); 
};

Group.cpp

#include "Group.h"
#include "User.h"

using namespace std;

class Group
{
    .....

    void show() {
        for(int i=0; i<m.size(); i++)
        cout << m[i]->getUsername() << "\n";
    }

    .....
 }

Then in the Group.cpp file, include User.

You can forward declare in the header anytime the object size doesn’t depend on the actual size of the object your forward declaring. In this case, (in Group) you use User as a pointer and therefore the size of Group is not dependent on the size of User it’s only storing a pointer which is independent of the User size.

Another tidbit which should help is that it’s bad practice to include namespaces (in your case std) in a header file. You should remove the “using” statement and do std::vector instead. Using a “using” in the cpp file is fine, as other code doesn’t “include” your source.

Leave a Comment