What are the reasons for this error Error: expected class-name before ‘{‘ token

  abstraction, c++, inheritance, oop

My code:

Animal.h


#ifndef ANIMAL_H

#define ANIMAL_H

#include <Cat.h>


#include <iostream>

using namespace std;

class Animal
{
    public:
        Animal( );

        void setName(string n);

        virtual string  getAnimalType(); //abstract method
         string getName();
         virtual void  makeNoise();//abstract method


    private:
        string name;
};

#endif // ANIMAL_H

Animal.cpp

#include "Animal.h"
Animal::Animal()
{

}

void Animal::setName(string n)
{
    name=n;
}


string Animal::getName()
{
    return name;
}

Cat.h

#ifndef CAT_H
#define CAT_H
#include <Animal.h>

#include <iostream>

using namespace std;




class Cat: public Animal
{
    public:
        Cat( );

        ~Cat();

        string getAnimalType();
        void makeNoise();

        void doKittyThings();


};

#endif // CAT_H

Cat.cpp

#include "Cat.h"
#include "Animal.h"


Cat::Cat( )
{
    setName("cat");
}


Cat::~Cat()
{
    setName(" ");
}

string Cat::getAnimalType()
{
    return "cat";
}

void Cat::makeNoise()
{
    cout<<"Meeeeeoooow!"<<endl;
}


void Cat::doKittyThings()
{
    cout<<"I am tearing up your couches  "<<endl;
}

Main.cpp

#include <iostream>

using namespace std;

#include <Cat.h>
#include <Animal.h>





int main()
{

    Animal *a1;
    Cat obj1;
    a1=&obj1;
    a1->makeNoise();



}

Note:I looked up the error message I got and many people had an issue with labeling their headers I see that I have this problem and can’t figure out why I’m getting this error message. I would really appreciate it if someone could give me insight on why I am getting this error message

Source: Windows Questions C++

LEAVE A COMMENT