各位:以下代碼何錯之有啊??
爲什麽老提示錯誤???
#include<iostream>
class base
{
int m1() { return 30; }
public:
virtual int m2() { return 40; }
virtual ~base() { }
};
class derived : public base
{
public:
int m2() { return 50; }
};
void main()
{
base *p_b = new base();
derived *p_d = new derived();
cout << "b->m3(): " << b->m3() << endl;
cout << "d->m3(): " << d->m3() << endl;
delete b;
b =d;
cout << "b_d->m3(): " << b->m3() <<endl;
delete d;
}
THX!!!!