有如下程序:
#include
using namespace std;
public:
AA( ){ cout<<’1’; }
};
class BB: public AA{
int k;
public:
BB( ):k(0){ cout<<’2’; }
BB(int n):k(n){ cout<<’3’;}
}
int main( ){
BB b(4), c;
return 0;
}
运行时的输出结果是
有如下程序
#include
using namespace std;
class Publication{ //出版物类
char name[30];
public:
Publication(char *name=”未知名称”){
strcpy(this->name,name);
}
const char * getName( )const{ return name; }
virtual const char * getType( )const{ return “未知类型”;}
};
class Book: public Publication{ //书类
public:
Book(char *name): Publication(name){}
virtual const char * getType( )const{ return “书“;}
};
void showPublication( Publication &p){
cout<
int main( ){
Book book(“精彩人生”);
showPublication(book);
return 0;
}
运行时的输出结果是
有如下程序
#include
using namespace std;
class A {
public:
A(int i):rl(i) {}
void print( ) {cout<<’e’<
int rl;
};
int main( ){
A al(2); const A a2(4);
Al.print( );a2.print( );
Return 0;
}
运行时的输出结果是
有如下程序
#include
using namespace std;
Class Base{
public:
Base(int x=0):valB(x) {cout<
~Base( ) {cout<
private:
int valB;
};
class Derived:public Base{
public:
Derived(int x=0,int y=0):Base(x),valD(y){cout<
~Derived( ) {cout<
private:
int valD;
};
int main( ){
Derived obj12(2,3);
retuen 0;
}
运行时的输出结果是()
有如下程序:
#include
using namespace std;
class Toy{
public:
Toy(char* _n) { strcpy (name,_n); count++;}
~Toy( ){ count--; }
char* GetName( ){ return name; }
static int getCount( ){ return count; }
private:
char name[10];
static int count;
};
int Toy::count=0;
int mail( ){
Toy t1(“Snoopy”),t2(“Mickey”),t3(“Barbie”);
cout<
}
运行时的输出结果是
我来回答: