摘要: class MatrixBase{ int rows, cols;public: MatrixBase(int the_rows, int the_cols) :rows(the_rows), cols(the_cols){} int GetRows()const { return rows; } 阅读全文
posted @ 2016-05-05 08:50 huninglei 阅读(230) 评论(0) 推荐(0) 编辑
摘要: class MyClass{ int value;public: MyClass(int i=10) { value = i; cout << "Constructor called." << endl; } MyClass( MyClass& p) { p.value = 11; value = 阅读全文
posted @ 2016-05-04 18:37 huninglei 阅读(203) 评论(0) 推荐(0) 编辑
摘要: class Room{ int room_no; double length; double width;public: Room(int the_room_no, double the_length, double the_width) :room_no(the_room_no), length( 阅读全文
posted @ 2016-05-04 13:32 huninglei 阅读(167) 评论(0) 推荐(0) 编辑
摘要: class book{ char* title; int num_pages; int cur_page;public: book(const char* theTitle, int pages) :num_pages(pages) { title = new char[strlen(theTitl 阅读全文
posted @ 2016-04-28 19:47 huninglei 阅读(286) 评论(0) 推荐(0) 编辑
摘要: class shape{public: virtual float perimeter() const{ return 0; } virtual float area()const { return 0; } virtual const char* name()const { return "抽象图 阅读全文
posted @ 2016-04-28 10:12 huninglei 阅读(308) 评论(0) 推荐(0) 编辑
摘要: class MyClass{ int member;public: MyClass(int x) :member(x){} //析构函数必须有“void”参数列表 ~MyClass(){} //需要访问类的成员变量时需要用友元函数 friend void judge(MyClass &obj);}; 阅读全文
posted @ 2016-04-26 18:19 huninglei 阅读(296) 评论(0) 推荐(0) 编辑
摘要: class book{ char* title;//书名 int num_pages;//页数 char * writer;//作者姓名public: book( char* the_title, int pages, const char* the_writer) :num_pages(pages 阅读全文
posted @ 2016-04-26 17:23 huninglei 阅读(327) 评论(0) 推荐(0) 编辑
摘要: #include "stdafx.h"#include "iostream"#include <ctime>using namespace std;//全局常量size=4const int size=4;template <typename T>class MyClass{public: MyCl 阅读全文
posted @ 2016-04-25 16:31 huninglei 阅读(3577) 评论(0) 推荐(0) 编辑
摘要: #include "stdafx.h"#include "iostream"#include <ctime>using namespace std;//getNum()获得数字字符串函数char * getNum(char *src, char *buf){ while (* src!='\0') 阅读全文
posted @ 2016-04-25 15:29 huninglei 阅读(318) 评论(0) 推荐(0) 编辑
摘要: #include "stdafx.h"#include "iostream" using namespace std; class MyClass{ int _i; friend void Increment(MyClass& f);public: const int NUM; //常量值的定义:N 阅读全文
posted @ 2016-04-10 11:53 huninglei 阅读(387) 评论(0) 推荐(0) 编辑