栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > C++面试题库

整理的金华业C++笔试题

整理的金华业C++笔试题

class A
{
public:
 A()
 {
  cout<<“A()”<<endl;
 }
 ~A()
 {
  cout<<“B()”<<endl;
 }
};
class B:public A
{
public:
 B()
 {
  cout<<“B()”<<endl;
 }
 ~B()
 {
  cout<<“B()”<<endl;
 }
};
class C:public B
{
public:
 C()
 {
  cout<<“C()”<<endl;
 }
 ~C()
 {
  cout<<“C()”<<endl;
 }
};
void main()
{
 A *a=new A;
 B *b=new B;
 C *c=new C;
 
 delete a;
 delete b;
 delete c;

 C pc;
 B pb;

}
请写出运行的结果。

class A
{
public:
 A()
 {
 }
 void show()
 {
  cout<<“1″<<endl;
 }
 ~A()
 {
 }
};
class B:public A
{
public:
 B()
 {
 }
 virtual void show()
 {
  cout<<“2″<<endl;
 }
 ~B()
 {
 }
};
class C:public B
{
public:
 C()
 {
 }
 void show()
 {
  cout<<“3″<<endl;
 }
 ~C()
 {
 }
};
void main()
{
 A *pa;
 B b;
 pa=&b;
 pa->show();

 B *pb;
 C c;
 
 pb=&c;
 pb->show();

 B *pb;
 pb=(B*)(&c);
 pb->show();

}
请写出运行结果

请写出string类完整的构造函数和析构函数,重载等号运算符。

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/265631.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号