学习啦>创业指南>职场>笔试题>

软件工程师笔试题

护托分享

  软件工程师是从事软件开发相关工作的人员的统称。下面就由学习啦小编为大家介绍一下软件工程师笔试题的文章,欢迎阅读。

  软件工程师笔试题篇1

  考察虚继承内存体系

  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

  考察非虚析构函数

  1、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; 因为析构函数是非virtual的,故析构的时候按照指针的类型进行析构

  }

  输出:

  Parent construct

  Child Construct

  Parent destruct

  2、 考察初始化列表的写法

  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);

  }

  软件工程师笔试题篇3

  1、考察拷贝构造函数和赋值的区别。

  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; //调用拷贝构造函数

  A c(a); //调用拷贝构造

  A d;

  d=a; //赋值

  }

  输出:

  Construct A by default //构造对象a

  consttuct A by copy //拷贝构造b

  consttuct A by copy //拷贝构造c

  Construct A by default //构造a

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

  Destruct A

  Destruct A

  Destruct A

  Destruct A

  2、 考察函数指针

  void func(char* a)

  {

  cout<

  }

  int main()

  {

  void (*fp)(char*); //填空处

  fp = func; //函数名func相当于函数的地址,将其赋给函数指针fp

  char* s="helloc";

  fp(s);

  }

    3169901