来自「visualCplusplus学习课件大连东软培训教材」· 代码 · 共 50 行
TXT
50 行
#include "stdafx.h"
#include <iostream.h>
class CBase
{
public:
CBase(int x, int y)
{
m_nX = x;
m_nY = y;
}
void Display()
{
cout << m_nX << " " << m_nY <<endl;
}
protected:
int m_nX;
int m_nY;
};
class CDerived : public CBase
{
public:
CDerived(int x, int , int z);
void Display();
protected:
private:
int m_nZ;
};
CDerived::CDerived(int x, int y, int z)
:CBase(x, y)
{
m_nZ = z;
}
void CDerived::Display()
{
cout << m_nX << " " << m_nY << " " << m_nZ <<endl;
}
void main()
{
CDerived *d = new CDerived(1, 2, 4);
CBase *b = d;
b->Display();
d->Display();
};
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?