- 相關(guān)推薦
EMC筆試題
1。class a{
public:
a() {cout<<"a!"<
virtual void disp(){cout<<" a::disp()!"<
virtual ~a(){cout<<"~a!"<
};
class b:public a{
public:
b(){cout<<"b!"<
~b(){cout<<"~b!"<
};
class c:public b{
public:
c(){cout<<"c!"<
void disp(){cout<<"c::disp()!"<
~c(){cout<<"~c!"<
};
void main()
{
a *p=new c();
p->disp();
delete p;
}
輸出結(jié)果:
a!
b!
c!
c::disp()!
~c!
~b!
~a!
若a構(gòu)造函數(shù)a()前沒有virtual關(guān)鍵字,輸出為a::disp()!
若a析構(gòu)函數(shù)~a()前沒有virtual關(guān)鍵字,輸出為~a!而不是~c!~b!~a!
2。寫一個函數(shù) int p(int i, int N);
能夠輸出i到N再到i,即以參數(shù)1,7調(diào)用函數(shù),輸出結(jié)果為
1
2
3
4
5
6
7
6
5
4
3
2
1
要求只用一個語句完成,不允許用?:等n多操作符和關(guān)鍵字。只能用一個printf庫函數(shù)
include
int p(int i, int N)
{
return (printf("%d\n", i))
&& ( i
&& (p(i+1, N)
|| (!printf("%d\n", i))));
}
int main(void)
{
p(1,7);
}
【EMC筆試題】相關(guān)文章:
EMC筆試歸來02-18
EMC實習筆試02-18
迅雷JAVA廣州站二筆筆試題目分享11-21
網(wǎng)易筆經(jīng)11-11
奧美筆經(jīng)02-23
騰訊筆試題 試題分享02-24
北京埃森折筆試回來,不是筆經(jīng)的筆經(jīng)11-21
殼牌Shell筆經(jīng)02-23