一道編程類筆試題
#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è)編程語言類英語詞匯10-09
華為2017筆試試題08-10
一道趣味心理測試題09-08
桂林銀行筆試題筆經(jīng)10-21
一道測試題的勵志故事07-14
一個C/C++編程面試題11-22
優(yōu)視科技一道指針筆試題目11-01