自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(29)
  • 收藏
  • 关注

原创 7.31友元成员函数

友元成员函数#include using namespace std;class Date;      class Clock     {public:Clock(int, int, int);void display(Date &); private:int hour;int minute;int second;};class Date    

2014-08-29 18:48:36 334

原创 7.31友元普通函数

友元普通函数#include using namespace std;class Clock  {public:Clock(int, int, int); friend void display(Clock &);   private:int hour;int minute;int second;};Clock::Clock(int h,int m,

2014-08-29 18:47:51 315

原创 8.1~8.7综合程序代码 未完待续。。。。。。。

访问静态数据成员。#include using namespace std;#include class Student{public:Student(char *Id = "uncertain", char *Name = "uncertain", char Sex = 'M');~Student( );static int stu_count;      p

2014-08-29 18:47:32 511

原创 7.30定义一个公共基类Shape,实现运行时的多态性

定义一个公共基类Shape,它表示一个封闭平面几何图形。然后,从Shape类派生出三角形类Triangle、矩形类Rectangle和圆类Circle,在基类中定义纯虚函数show和area,分别用于显示图形信息和求相应图形的面积,并在派生类中根据不同的图形实现相应的函数。要求实现运行时的多态性。#include #includeusing namespace std;

2014-08-29 18:46:48 2425

原创 7.29交通工具类

有一个交通工具类vehicle,将它作为基类派生出汽车类motor_ vehicle,再将汽车类motor_ vehicle 作为基类派生出小汽车类car和卡车类truck,声明这些类并定义一个虚函数用来显示各类信息。#include using namespace std;class vehicle{public: virtual void message( )  

2014-08-29 18:44:30 1226

原创 7.29虚函数的作用

虚函数的作用#include using namespace std;class Point{public:Point(double a = 0, double b = 0) {  x = a; y = b;   }virtual double Area( ) {   cout return 0.0; } protected:double x, y;

2014-08-29 18:43:56 367

原创 7.30在交通工具类vehicle中使用虚析构函数。

在交通工具类vehicle中使用虚析构函数。#include using namespace std;class vehicle     {public:vehicle( ){}     virtual ~vehicle( )  {   cout private:int wheels;float weight;};class motor_vehicl

2014-08-29 18:42:57 569

原创 7.27多重继承派生类的构造函数

多重继承派生类的构造函数#includeusing namespace std;class Employee: public Person  {public:Employee(char *Name, char Sex, int Age, char *Num, char *Clerk, char *Depart, char *Timer): Person(Name, Sex, A

2014-08-29 18:40:46 459

原创 7.28组合

组合class Student     {public:        Student(string num, string name, char sex, int age): num(num),name(name), sex(sex), age(age){ }private:        string num;        string name;     

2014-08-29 18:40:00 370

原创 7.28基类对象的指针指向公用派生类对象的应用。

基类对象的指针指向公用派生类对象的应用。#include using namespace std;class Point       {public:Point(double a = 0, double b = 0) {  x = a; y = b;  }void Show( ) { cout protected:double x, y; };class

2014-08-29 18:39:32 379

原创 7.27派生类的析构函数

派生类的析构函数#includeusing namespace std;# includeclass Person         {public:Person(char *Name, char Sex, int Age ) {  name = new char[strlen(Name)+1];strcpy(name, Name); sex = Sex; age =

2014-08-29 18:37:27 294

原创 7.26派生类的构造函数

/*派生类的构造函数*/ #include  using namespace std;  # includeclass Person           {public:Person(char *Name, char Sex, int Age )  {  strcpy(name, Name); sex = Sex; age = Age;cout }~Pers

2014-08-09 12:41:10 342

原创 7.26派生类成员函数与基类成员函数同名

/*派生类成员函数与基类成员函数同名*/#include using namespace std;class Circle    {public:         void Set(int r){  radius = r;  }    void Show( ){  cout private:        int radius; };class Cy

2014-08-09 12:38:49 865

原创 7.25私有继承、保护继承

私有继承、保护继承#includeusing namespace std;class Cylinder: private Circle  {public:            void SetHeight(int h){  height = h;  }    int GetHeight( ){  return height;  }      void ShowHeig

2014-08-09 00:36:14 292

原创 7.25公用继承

公用继承#include using namespace std;class Circle     {public:            void SetRadius(int r){  radius = r;  }      int GetRadius( ){  return radius;  }         void ShowRadius( )        

2014-08-09 00:31:24 295

原创 7.24常指针 常对象 常引用

常对象一般形式const 类名 对象名(实参表)类名 const 对象名(实参表)指向对象的常指针类名 *const 指针名=&类的对象Box box(1,2,3);Box *const pbox=&box;指向常对象的指针const 类名 *指针名const Clock clock1(1,2,3);const Clock *p1=&cloc

2014-08-08 23:53:13 335

原创 7.24定义对象数组,并初始化

/*定义对象数组,并初始化*/#includeusing namespace std;class Box{public:Box(){length=1;width=2;height=3;coutcout}Box(float L,float W,float H){length=L;width=W;height=Hcoutfloat Volume(){

2014-08-08 23:33:16 393

原创 7.23构造函数和析构函数的调用次序

/*构造函数和析构函数的调用次序*/#includeusing namespace std;class Box{public:Box(){length=1;width=2;height=3;coutcout}Box(float L,float W,float H){length=L;width=W;height=Hcoutfloat Volume

2014-08-08 23:19:29 333

原创 7.23带参数的构造函数

/*带参数的构造函数*/#includeusing namespace std;class Box{public:Box(float L,float W,float H){length=L;width=W;height=H;}float volume(){return length*width*height;}private:float length;float

2014-08-08 00:13:06 340

原创 7.23构造函数

/*构造函数*/#includeusing namespace std;class Box{public:Box{length=1;width=2;height=3;}void Show(){cout}private:{      float length,width,height;};int main(){Box b

2014-08-07 23:39:52 280

原创 7.22通过对象的引用访问对象中的成员

/*通过对象的引用访问对象中的成员*/#includeusing namespace std;class Test{public:void Set(char ch){c=ch;}void Show(){coutprivate:char c;};int main(){Test test;test1.Set('a');Test &re

2014-08-07 23:25:18 493

原创 7.22通过指向对象的指针访问对象中的成员

/*通过指向对象的指针访问对象中的成员pTest->Show(),(*pTest).Show(),test1.Show等价*/#includeusing namespace std;class Test{public:void Set(char ch){c=ch;}void Show(){coutprivate:char c;};int main()

2014-08-07 23:23:00 949

原创 7.22相同类的不同对象执行相同成员函数输出不同结果

相同类的不同对象执行相同成员函数输出不同结果#includeusing namespace std;class Test{public:void Set(char ch){c=ch;}void Show(){coutprivate:char c;};int main(){Test test1,test2;test1.Set('a');test

2014-08-07 23:13:26 508

原创 7.21类外定义成员函数

类外定义成员函数#includeusing namespace std;class Student{public:void show();private:{   string stuNO;   string stuName;   string stuSex;};void Student::Show(){coutcoutcout

2014-08-07 00:06:59 378

原创 7.20在学生类student和教师类teacher 基础上再派生出一个助教类

/*在学生类student和教师类teacher基础上再派生出一个助教类TeachAssistant,一个助教既具有教师的特征,又具有学生的特征,还有自己的新特征:工资(wage)。要求将助教类的间接共同基类声明为虚基类。*/#include#includeusing namespace std;class Person{public:void input(){

2014-08-06 23:58:24 5100

原创 7.20学生和教师数据输入和显示的程序

/*编写一个用于学生和教师数据输入和显示的程序,学生数据要求有编号、姓名、班号和成绩,教师数据有编号、姓名、职称和部门。要求将编号、姓名的输入和显示设计成一个类person,并作为学生类student和教师类teacher的基类,学生数据中的班号和成绩的输入和显示在student类中实现,教师数据中的职称和部门的输入和显示在teacher类中实现。最后在main函数中进行该

2014-08-06 23:58:05 1721

原创 7.21声明一个学生类(学号,姓名,性别)同时定义对象

#includeusing namespace std;class Student{public:void show(){coutcoutcout}private:{   string stuNO;   string stuName;   string stuSex;}zhang,wang;

2014-08-06 23:54:08 1273

原创 1

#includeint main(){   int *p;  /*p是变量的名字,int * 表示p变量存放的是int类型变量的地址*/   int i=3;   p=&i; /*ok,p=i; error,因为类型不一致,p只能存放int类型的变量地址,不能存放int类型变量的值。p=55错误的原因也为此*/    return 0;}

2014-02-08 22:27:58 672

原创 c语言期末编程题

1 .设N是一个四位数,它的9倍恰好是其反序数(例如:123的反序数是321),求N的值。#includeint main (){   int n;   int a,b,c,d;   for(n=1000;n   {      a=n/1000;      b=n100%10;      c=n/10%10;      d=n%10;      if

2014-01-19 20:00:08 1297

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除