two c++ interview questions! (转载)# Programming - 葵花宝典
x*o
1 楼
【 以下文字转载自 JobHunting 讨论区 】
发信人: xltao (iii), 信区: JobHunting
标 题: two c++ interview questions!
发信站: BBS 未名空间站 (Wed Sep 19 15:09:11 2007)
#include
using namespace std;
class A
{
protected:
int nValue;
public:
A( int n ) : nValue( n )
{
nValue++;
}
};
class B : public A
{
public:
B( int n ) : A( n * 10 )
{
this->nValue += 50;
}
void Output()
{
cout << nValue << endl;
}
};
int main()
{
B b( 10 );
b.Output();
retu
发信人: xltao (iii), 信区: JobHunting
标 题: two c++ interview questions!
发信站: BBS 未名空间站 (Wed Sep 19 15:09:11 2007)
#include
using namespace std;
class A
{
protected:
int nValue;
public:
A( int n ) : nValue( n )
{
nValue++;
}
};
class B : public A
{
public:
B( int n ) : A( n * 10 )
{
this->nValue += 50;
}
void Output()
{
cout << nValue << endl;
}
};
int main()
{
B b( 10 );
b.Output();
retu