I learned C++ using the Code::Blocks. However, the compiler gives me an error in the file Daughter.h, line 6, saying "error: expected-class name before '{' token"
when I am trying to implement the inheritance. That confuses me more because the tutorial I'm watching using Code::Blocks and compiler in this tutorial does not gives any errors, it in fact works perfectly. I am a bit frustrated at this point. Does anybody know how to make it work? Here are all of my files:
main.cpp
//main.cpp
#include "Daughter.h"
#include "Mother.h"
#include <iostream>
using namespace std;
int main()
{
Mother jelo;
jelo.sayname();
Daughter tina;
tina.sayname();
}
Mother.h
//Mother.h
#ifndef MOTHER_H
#define MOTHER_H
class Mother
{
public:
Mother();
void sayname();
};
#endif // MOTHER_H
Mother.cpp
//Mother.cpp
#include "Daughter.h"
#include "Mother.h"
#include <iostream>
using namespace std;
Mother::Mother()
{
}
void Mother::sayname() {
cout << "I am Roberts" << endl;
}
Daughter.h
//Daughter.h
#ifndef DAUGHTER_H
#define DAUGHTER_H
class Daughter: public Mother
{
public:
Daughter();
};
#endif // DAUGHTER_H
Daughter.cpp
//Daughter.cpp
#include "Daughter.h"
#include "Mother.h"
#include <iostream>
using namespace std;
Daughter::Daughter()
{
}