1024国产,91精品国产综合久久福利,中文字幕成人免费视频,日本人的色道免费网站,曰本一级毛片免费,www.日日爱,国产黑丝视频

當(dāng)前位置:高考升學(xué)網(wǎng) > 招聘筆試題 > 正文

艾默生軟件工程師筆試題和面試題答案

更新:2023-09-18 12:47:33 高考升學(xué)網(wǎng)

1.考察虛繼承內(nèi)存體系

  class A

  {

  public:

  A() { cout<<"Construct A"<

  ~A() { cout<<"Destruct A"<

  void speak() { cout<<"A is speaking!"<

  };

  class B:public virtual A

  {

  public:

  B() { cout<<"Construct B"<

  ~B() { cout<<"Destruct B"<

  };

  class C:public virtual A

  {

  public:

  C() { cout<<"Constuct C"<

  ~C() { cout<<"Destruct C"<

  };

  class D:public B, public C

  {

  public:

  D(){ cout<<"Constsruct D"<

  ~D(){ cout<<"Destruct D"<

  };

  int main()

  {

  D p = new D();

  p->speak();

  delete p;

  }

  輸出:

  Construct A

  Construct B

  Constuct C

  Constsruct D

  A is speaking!

  Destruct D

  Destruct C

  Destruct B

  Destruct A

2.考察非虛析構(gòu)函數(shù)這道題

  class Parent

  {

  public:

  Parent(){cout<<"Parent construct"<

  ~Parent(){ cout<<"Parent destruct "<

  };

  class Child : public Parent

  {

  public:

  Child() { cout<<"Child construct "<

  ~Child() {cout<<"child destruct"<

  };

  int main()

  {

  Parent p;

  Child c = new Child();

  p = c;

  delete p; // 因?yàn)槲鰳?gòu)函數(shù)是非 virtual 的,故析構(gòu)的時(shí)候按照指針的類(lèi)型進(jìn)行析構(gòu)

  }

  輸出:

  Parent construct

  Child Construct

  Parent destruct

3.考察初始化列表的寫(xiě)法

  class A

  {

  public:

  A(int x, int y, int z):a=x,b=y,c=z {} (1)

  A(int x, int y, int z):a(x),b(y),c(z){} (2)

  private:

  int a;

  int b;

  int c;

  };

  int main()

  {

  A a(1,2,3);

  }

第 1 種寫(xiě)法是錯(cuò)誤的,第 2 種正確。

4.考察拷貝構(gòu)造函數(shù)和賦值的區(qū)別。

  class A

  {

  public:

  A() { cout<<"Construct A by default"<

  A(const A& a) { cout<<"consttuct A by copy"<

  A& operator =(const A& a) { cout<<"cosnt A by operator ="<

  ~A() { cout<<"Destruct A"<

  };

  int main()

  {

  A a;

  A b=a; //調(diào)用拷貝構(gòu)造函數(shù)

  A c(a); //調(diào)用拷貝構(gòu)造

  A d;

  d=a; //賦值

  }

  輸出:

  Construct A by default //構(gòu)造對(duì)象 a

  consttuct A by copy //拷貝構(gòu)造 b

  consttuct A by copy //拷貝構(gòu)造 c

  Construct A by default //構(gòu)造 a

  cosnt A by operator = //賦值 d=a

  Destruct A

  Destruct A

  Destruct A

  Destruct A

5.考察函數(shù)指針

  voidfunc(char a)

  {

  cout<

  }

  int main()

  {

  void (fp)(char); //填空處

  fp = func; //函數(shù)名func相當(dāng)于函數(shù)的地址,將其賦給函數(shù)指針fp

  char s="helloc";

  fp(s);

  }

最新圖文

2020年河北新聞網(wǎng)兩學(xué)一做

時(shí)間:2023-09-18 07:0:24

2020年河北新聞網(wǎng)兩學(xué)一做

時(shí)間:2023-09-15 11:0:59

兩學(xué)一做學(xué)習(xí)教育知

時(shí)間:2023-09-21 06:0:30