摘要: /*new delete*/#include"stdafx.h"#include <stdlib.h>#include <iostream.h>#include <string.h>struct student{ student() { cout << "student::student()" << endl; } student( ch... 阅读全文
posted @ 2010-01-21 20:52 o无尘o 阅读(230) 评论(0) 推荐(0)
摘要: /*类构造函数(4)*/#include"stdafx.h"#include <string.h>#include <iostream.h>class Date{public: //表达式表构造 Date( int nYear = 1980 , int nMonth = 1, int nDay = 1 ) :m_nYear(nYear),m_nMonth(nMonth),m... 阅读全文
posted @ 2010-01-21 20:32 o无尘o 阅读(197) 评论(0) 推荐(0)
摘要: /*类的构造函数(3)*/ /*******************类文件***********************/ #include"stdafx.h"#include"A.h"//////////////////////////////////////////////////////////////////////// Construction/Destruction/////////... 阅读全文
posted @ 2010-01-21 20:11 o无尘o 阅读(173) 评论(0) 推荐(0)
摘要: /*类的构造函数(2)*/#include"stdafx.h"#include <iostream.h>class Color{public: Color() { cout << this << " color 无参构造" << endl; } ~Color() { cout << this << " color 析构" &l... 阅读全文
posted @ 2010-01-21 19:48 o无尘o 阅读(180) 评论(0) 推荐(0)
摘要: /*类的构造函数(1)*/#include"stdafx.h"#include <iostream.h>class Time{private: //私有段 int m_nHour; int m_nMin; int m_nSecond;public: //公有段 //构造函数无返回值,名称是类名 //进入到构造对象已经存在,无法销毁 Time() { init(); cout <... 阅读全文
posted @ 2010-01-21 19:33 o无尘o 阅读(201) 评论(0) 推荐(0)
摘要: /************************************************************************C语言指针,难吗!!!???不难!************************************************************************//************************************... 阅读全文
posted @ 2010-01-21 16:42 o无尘o 阅读(161) 评论(0) 推荐(0)
摘要: /*再来看看this指针*//************************************************************************1.通过写程序证明,C++中的成员变量是独立的,成员方法是共享的。************************************************************************/#includ... 阅读全文
posted @ 2010-01-21 15:59 o无尘o 阅读(199) 评论(0) 推荐(0)
摘要: /*讲讲this指针*///同样声明一个类class CMyPoint{private: //私数据成员 int m_nx; int m_ny; public: //公有成员函数声明+实现, 如果在类内中定义成员函数,它是内联函数 void setpoint(int nx,int ny) { //在成员函数中,可以使用类中定义的数据成员 /**************************... 阅读全文
posted @ 2010-01-21 15:45 o无尘o 阅读(148) 评论(0) 推荐(0)
摘要: /*开始学习类 */class person //class关键字声明一个类{private: //声明下面的成员为私有,就是只有类内部的成员才能使用,类外部就使用不了 int sex; //一个非常简单的私有数据成员 public: //声明下面的成员为公有,在类外部可以直接调用,下面的函数可以直接访问上面的私有成员 int height; //非常简单的公有数据,可以在类外部直接使用 int ... 阅读全文
posted @ 2010-01-21 15:05 o无尘o 阅读(174) 评论(0) 推荐(1)