Hi all,
I am learning about RTTI, but I really don't know where the error is. Please check it out for me.
#include<iostream>
#include<typeinfo>
using namespace std;
class Base
{
virtual void f() {}; // make Base polymorphic
// ...
};
class Derived1: public Base
{
// ...
};
class Derived2: public Base
{
// ...
};
int mian()
{
Base *p, baseob;
Derived1 ob1;
Derived2 ob2;
p = &baseob;
cout << "p is pointing to an object of type ";
cout << typeid(*p).name() << endl;
p = &ob1;
cout << "p is pointing to an object of type ";
cout << typeid(*p).name() << endl;
p = &ob2;
cout << "p is pointing to an object of type ";
cout << typeid(*p).name() << endl;
return 0;
}
The compile's error is the following:
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/rtti.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
Best Regards,
zawpai