this->x=x;this->y=y; } void Point::Show() {
cout<<"("<<x<<","<<y<<")"<<en dl; }
-
//Circle.h文件 #ifndef CIRCLE_H #define CIRCLE_H #include <iostream> #include "Point.h" using namespace std; class Circle:public Point { protected:
name=nam; sex=s; } ~Student( ){ } protected: int num; string name; char sex ; };
-
class Student1: public Student { public:
Student1(int n,string nam,char s,int a,string ad):Student(n,nam,s)
using namespace
std;
{ protected:
class Base
int j;
{ protected:
int i; public:
void F()
public: void Fun() { i=20; }
};
{
void main()
} };
{ Drived d;
}
-
4.5 派生类的构造函数和析构函数
如程序PointRect1所示:
-
4.4继承方式