随笔分类 -  C++语言

1 2 下一页
线性表--数组实现+模板+迭代器
摘要:文件栏去下载 阅读全文
posted @ 2010-02-25 16:24 o无尘o
智能指针(2)
摘要:#include"stdafx.h"#include <iostream.h>#include <string.h>template <class T> classVector{ T *v; int sz;public: Vector(int s) { v=new T[s]; sz=s; } int size( ) { return sz; } T&... 阅读全文
posted @ 2010-02-09 21:15 o无尘o
IO流(2)
摘要:#include"stdafx.h"#include <fstream.h>#include <string.h>int main(int argc, char* argv[]){ ofstream of; of.open("ofstream.txt", ios::out | ios::binary); if ( !of.fail()) { of << 10... 阅读全文
posted @ 2010-02-09 20:52 o无尘o
IO流(1)
摘要:#include"stdafx.h"#include <iostream.h>#include <string.h>#include <strstrea.h>class Student{public: Student(const char *pStr,int nAge = 20) : m_nAge(nAge) { if ( pStr == NULL ) { //... 阅读全文
posted @ 2010-02-09 20:51 o无尘o
异常(3)
摘要:#include"stdafx.h"#include <iostream.h>#include <string.h>//类描述异常信息class Matherr{protected: char m_szMsg[32];public: virtual const char *GetMsg()const { return m_szMsg; }};class Overflow... 阅读全文
posted @ 2010-02-09 19:55 o无尘o
异常(2)
摘要:#include"stdafx.h"#include <iostream.h>classVector{private: int *p; int m_nLen;public: Vector(int nLen) { p = newint [nLen]; m_nLen = nLen; } ~Vector( ) { delete [] p; } int size() { retu... 阅读全文
posted @ 2010-02-09 19:44 o无尘o
异常(1)
摘要:#include"stdafx.h"#include <iostream.h>#include <string.h>class DivideZero{public: //带参构造 DivideZero( const char* pStr ) { strcpy(szMessage, pStr); } //拷贝构造 DivideZero(const DivideZero &am... 阅读全文
posted @ 2010-02-09 18:37 o无尘o
模板(3)
摘要:#include"stdafx.h"#include <stdlib.h>#include <iostream.h>//整形数组//对元素进行管理的类,可以叫容器类template<typename T, int nSize = 5>class IntegerArray{private: T *m_pIntegerArray; //大小 int m_nSize;... 阅读全文
posted @ 2010-02-04 22:28 o无尘o
模板(2)
摘要:/*************************B.h*********************************************/#if !defined(AFX_B_H__21773A49_ECD0_4400_9640_F7C306E01F51__INCLUDED_)#define AFX_B_H__21773A49_ECD0_4400_9640_F7C306E01F51__... 阅读全文
posted @ 2010-02-04 22:25 o无尘o
模板(1)
摘要:/*模板(1)*/#include"stdafx.h"#include <iostream.h>#include <string.h>class A{ int m_nData;public: A(int nData ) : m_nData(nData) { } //重载 > intoperator>( const A& Obj ) { return (m... 阅读全文
posted @ 2010-02-04 22:18 o无尘o
运算符重载简单应用--统计输入同样字符串的次数
摘要:/****************************Assoc.h**************************************/#if !defined(AFX_ASSOC_H__FBB8B380_5C3D_4A4D_A497_B45C77B2BDAE__INCLUDED_)#define AFX_ASSOC_H__FBB8B380_5C3D_4A4D_A497_B45C77... 阅读全文
posted @ 2010-02-04 21:24 o无尘o
运算符重载--智能指针
摘要:/*运算符重载--智能指针*/#include"stdafx.h"#include <iostream.h>class CPerson{private: int m_nAge;public: void sayHello() { this->m_nAge = 10; cout << "sayHello" << endl; }};class PerPtr {p... 阅读全文
posted @ 2010-02-02 20:41 o无尘o
操作符重载(2)
摘要:/*操作符重载(2)*/#include"stdafx.h"#include <iostream.h>#include <string.h>class MyInt{private: int m_nData; char* m_pStr;public: //转换构造函数 带参构造 MyInt( int nData ) { m_nData = nData; m_pStr = ne... 阅读全文
posted @ 2010-02-01 20:32 o无尘o
操作符重载
摘要:/*操作符重载*/#include"stdafx.h"#include <iostream.h>class Interger{private: int m_nData;public: int GetData() const { return m_nData; } intAdd( int nData ) { return m_nData + nData; }public: //带参构造 ... 阅读全文
posted @ 2010-02-01 20:12 o无尘o
虚继承
摘要:/*虚继承*/#include"stdafx.h"#include <iostream.h>class furniture{public: furniture( int nWeight ) { m_nWeight = nWeight; cout << "家具的构造" << endl; } int m_nWeight;};//虚继承//使派生类对象只有一份基类(f... 阅读全文
posted @ 2010-01-30 19:06 o无尘o
纯虚函数
摘要:/*纯虚函数*/#include"stdafx.h"#include <iostream.h>class IShape{public: //表示这个虚函数是纯虚函数 //如果一个类中只要有一个纯虚函数,那么这个类就是抽象类 //抽象类不能创建实例 virtualdouble Area() = 0; //派生类中一定要把抽象基类中纯虚函数覆盖 //=0 仅仅表示是纯虚函数,};//=0... 阅读全文
posted @ 2010-01-30 19:02 o无尘o
基类与子类的成员函数的关系
摘要:/****基类与子类的成员函数的关系*****/#include"stdafx.h"#include <iostream.h>class Base{public: void f() { cout << "Base::f" << endl;} void f(int i) { cout << "Base::f(int i)" << endl;... 阅读全文
posted @ 2010-01-29 22:16 o无尘o
虚函数--手工实现简单虚表
摘要:/*******************************Person.h*****************************/ #if !defined(AFX_PERSON_H__7862BC0E_A397_4133_AEEF_0F6FEF6B9F43__INCLUDED_)#define AFX_PERSON_H__7862BC0E_A397_4133_AEEF_0F6FEF6B... 阅读全文
posted @ 2010-01-29 15:42 o无尘o
虚函数的简单应用
摘要:/*虚函数的简单应用*/ /*******************************Shape.h***********************************/#if !defined(AFX_SHAPE_H__0DFF4B12_4075_4594_84F1_CD0039366CE1__INCLUDED_)#define AFX_SHAPE_H__0DFF4B12_4075_45... 阅读全文
posted @ 2010-01-29 15:17 o无尘o
虚函数(2)
摘要:/*虚函数(2)*/class CEmployee {public: CEmployee() { nTemp = 9; } virtual ~CEmployee();public: int nTemp; virtualvoid ShowWage(void) { cout << this << ": 员工发工资方法" << endl; }};class CItem... 阅读全文
posted @ 2010-01-27 21:47 o无尘o

1 2 下一页