问题代码:
[mw_shl_code=cpp,true]
#include "stdafx.h"
#include <iostream>
using namespace std;
//基类
class point{
private:
int x;
int y;
public:
void setCoorVal(int a, int b)
{
x = a;
y = b;
}
int getCoorX()
{
return x;
}
int getCoorY()
{
return y;
}
};
//派生类
//class 派生类 :派生方式 基类
class point3D :public point
{
private:
int z;
public:
int _tmain(int argc, _TCHAR* argv[])
{
int xVal, yVal;
point *myPoint = new point;
point3D *myPoint3D = new point3D;
//派生类调用从基类继承的函数setCoorVal()
myPoint->setCoorVal(100, 200);
myPoint3D->setCoorZ(300);
myPoint3D->printCoorVal();