I'm rather confused on the answers I find on the error at hand.
I have one class which i want to inherit from. But when I try to inherit I get the said error. Non of these classes use header files, since i'm only doing this to learn how virtual overrides work. I'm pretty new to C++. So this isn't about actually making something, more like understanding C++ better.
When I look for the answer on google, It usually ends up in problems with header files and "#include" keywords.
And there isn't much code to work with either. Any suggestions?
edit:
Like i said not much code to work with, also the other files I didnt include are no different than Pianist
/*
* File: main.cpp
* Author: Sidar
*
* Created on 19 juli 2011, 17:51
*/
#include <cstdlib>
#include <iostream>
#include "Musician.cpp"
#include "Pianist.cpp"
#include "MasterPianist.cpp"
#include "JuniorPianist.cpp"
using namespace std;
/*
*
*/
int main(int argc, char** argv) {
Musician *m = new Musician();
Pianist *p = new Pianist();
//JuniorPianist *jp = new JuniorPianist();
MasterPianist *mp = new MasterPianist();
//__________________________
cout << "Pianist greets:\n";
m->greet();
cout << "And this is a:\n";
m = p;
m->greet();
cout << "The pianist states his proffesion:\n";
m = mp;
m->greet();
cout << "And this is his student:\n";
// m = jp;
m->greet();
return 0;
}
Class to be inherited
#include <iostream>
using namespace std;
class Musician{
public:
//Constructors
Musician(){}
Musician(const Musician& m){}
~Musician(){}
//Methods/Functions
virtual void greet(){
cout << "Hello";
}
};
Class which tries to inherit.
/*
* File: Pianonist.cpp
* Author: Sidar
*
* Created on 19 juli 2011, 17:58
*/
#include <iostream>
using namespace std;
class Pianist: public Musician {
public:
Pianist(){}
Pianist(const Pianist& orig){}
~Pianist() {}
//____________________________________
void greet(){
cout << " This is pianist";
}
};