網站首頁 工作範例 辦公範例 個人範例 黨團範例 簡歷範例 學生範例 其他範例 專題範例

軟體工程師筆試題

欄目: 筆試題目 / 釋出於: / 人氣:1.21W

軟體工程師是從事軟體開發相關工作的人員的統稱。下面就由本站小編為大家介紹一下軟體工程師筆試題的文章,歡迎閱讀。

軟體工程師筆試題

軟體工程師筆試題篇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);

}