dimanche 19 juin 2016

Cpp(codeblocks) does not name a type


I was trying to write a person-dog program using codeblocks. Here is my project structure. file structure

I wrote the class dog as follows:

class dog
{
    public:
        std::string name;
        int age;
        //person  master;
        dog();
        dog(std::string name,int age);
        dog(std::string name);
        virtual ~dog();
        dog(dog & d);
        void bark();
    protected:
    private:
};

The class persion is defined in persion.h and I included it in dog.h. However I still get "does not name a type error". Also, I tried to forward declare person and add class person before the definition of the class dog. But that way, I can only use person * master, instead of person master as the filed of dog, which is not what I want. So where does this go wrong? How can I fix this error?

Thank you very much.


Aucun commentaire:

Enregistrer un commentaire