Hello, Working on this assignment for class and I keep getting these errors, I have pasted the code below, could someone look at it and see what I'm doing wrong?
Thanks Alot
5 error(s), 0 warning(s)
1. error C2065: 'cout' : undeclared identifier
2. error C2297: '<<' : illegal, right operand has type 'char [39]'
3. error C2065: 'endl' : undeclared identifier
4. error C2297: '<<' : illegal, right operand has type 'char [39]'
5. error C2297: '<<' : illegal, right operand has type 'char [27]'
public:
BaseClass() { }
void f(char *s = "unknown") {
cout << "Function f() in BaseClass called from " << s << endl;
h();
}
protected:
void g(char *s = "unknown") {
cout << "Function g() in BaseClass called from " << s << endl;
}
private:
void h() {
cout << "Function h() in BaseClass\n";
}
};
class Derived1Level1 : public virtual BaseClass {
public:
void f(char *s = "unknown") {
cout << "Function f() in Derived1Level1 called from " << s << endl;
g("Derived1Level1");
h("Derived1Level1");
}
void h(char *s = "unknown") {
cout << "Function h() in Derived1Level1 called from " << s << endl;
}
};
class Derived2Level1 : public virtual BaseClass {
public:
void f(char *s = "unknown") {
cout << "Function f() in Derived2Level1 called from " << s << endl;
g("Derived2Level1");
// h(); // error: BaseClass::h() is not accessible
}
};
class DerivedLevel2 : public Derived1Level1, public Derived2Level1 {
public:
void f(char *s = "unknown") {
cout << "Function f() in DerivedLevel2 called from " << s << endl;
g("DerivedLevel2");
Derived1Level1::h("DerivedLevel2");
BaseClass::f("DerivedLevel2");