MS Visual C++ 6.0 Errors in Code

Jan 14, 2009 at 1:51am
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]'


-------------------------------------------------------------------------------



class BaseClass {

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");

}
};
Last edited on Jan 14, 2009 at 1:51am
Jan 14, 2009 at 2:44am
Did you #include <iostream.h>?

Get yourself a newer compiler. 6.0 is too outdated,
Jan 14, 2009 at 2:46am
1
2
#include <iostream>
using namespace std;

Jan 14, 2009 at 3:03am
VC++ 6.0 uses iostream.h, not iostream. And there's no std namespace, either.
Jan 14, 2009 at 10:43pm
Hello,
When I added #include <iostream.h> then select build I receive this error below.


Configuration: Homework 1 - Win32 Debug--------------------
Linking...
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/Homework 1.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

Homework 1.exe - 2 error(s), 0 warning(s)
Jan 15, 2009 at 12:37am
There's no main().
Topic archived. No new replies allowed.