一道編程類筆試題
#include <iostream>
using namespace std;
class A
{
protected:
int m_data;
public:
A(int data = 0){m_data = data; }
int GetData(){return doGetData();}
virtual int doGetData(){ return m_data;}
};
class B:public A
{
protected:
int m_data;
public:
B(int data = 1){m_data = data; }
int doGetData(){ return m_data;}
};
class C:public B
{
protected:
int m_data;
public:
C(int data = 2){m_data = data; }
};
int main()
{
C c(10);
cout<<c.GetData()<<endl;
cout<<c.A::GetData()<<endl;
cout<<c.B::GetData()<<endl;
cout<<c.C::GetData()<<endl;
cout<<c.doGetData()<<endl;
cout<<c.A::doGetData()<<endl;
cout<<c.B::doGetData()<<endl;
cout<<c.C::doGetData()<<endl;
system("PAUSE");
return 0;
}
///////////////////////////////////////////////////////
運(yùn)行的結(jié)果是
1
1
1
1
1
0
1
1
【一道編程類筆試題】相關(guān)文章:
華為2017筆試題08-16
360筆試題目10-20
JAVA編程面試題及答案09-16
it職業(yè)編程語(yǔ)言類英語(yǔ)詞匯10-09
華為2017筆試試題08-10
一道趣味心理測(cè)試題09-08
桂林銀行筆試題筆經(jīng)10-21
一道測(cè)試題的勵(lì)志故事07-14
一個(gè)C/C++編程面試題11-22
優(yōu)視科技一道指針筆試題目11-01