c++构造器问题
不知道问题出在哪。、、,希望大家帮忙一下#include<iostream.h>
#include<string.h>
class BaseClass
{
public:
BaseClass();
~BaseClass();
void dosomething();
};
class SubClass:public BaseClass
{
SubClass;
~SubClass;
}
BaseClass::BaseClass()
{
std::cout<<"进入基类构造器....\n";
std::cout<<"我在基类构造器中干了某些事.....\n";
}
BaseClass::~BaseClass()
{
std::cout<<"进入基类析造器....\n";
std::cout<<"我在基类析造器中干了某些事.....\n";
}
void BaseClass::dosomething()
{
std::cout<<"我干了某些事。。。。\n";
}
SubClass::SubClass()
{
std::cout<<"进入子类构造器....\n";
std::cout<<"我在子类构造器中还干了某些事.....\n";
}
SubClass::~SubClass()
{
std::cout<<"进入子类析造器....\n";
std::cout<<"我在子类析造器中干了某些事.....\n";
}
int main()
{
SubClass subclass;
subclass.dosomething();
std::cout<<"完美,收工"<<endl;
return 0;
} class SubClass:public BaseClass
{
SubClass;
~SubClass;
} ;注意这里 缺个分号{:9_240:}
页:
[1]