摘要: // template.cpp : 定义控制台应用程序的入口点。#include "stdafx.h"#include #include #include #include #include // std::time#include // std::rand, std::srandusing namespace std;//类模板/////////////////////////////////////////////////templateclass myClass{ private: T1 I; T2 J; public: myClass(T1 a, T2 b)... 阅读全文
posted @ 2013-09-13 17:29 CPYER 阅读(472) 评论(0) 推荐(0) 编辑
摘要: 一,原型void * memcpy ( void * destination, const void * source, size_t num );功能:将以source作为起始地址的数据复制num个字节到以destination为起始地址的数据中,不支持destination和source重叠的情况。函数返回destination指针。void* memcpy (void* destination,constvoid* source,size_t num ){ char* pdes =(char*)destination; char* psrc =(char*)source; asse... 阅读全文
posted @ 2013-09-13 14:15 CPYER 阅读(765) 评论(0) 推荐(0) 编辑
摘要: 背景:在C&C++中一、inline关键字用来定义一个类的内联函数,引入它的主要原因是用它替代C中表达式形式的宏定义。表达式形式的宏定义一例:#define ExpressionName(Var1,Var2) ((Var1)+(Var2))*((Var1)-(Var2))为什么要取代这种形式呢:1. 首先谈一下在C中使用这种形式宏定义的原因,C语言是一个效率很高的语言,这种宏定义在形式及使用上像一个函数,但它使用预处理器实现,没有了参数压栈,代码生成等一系列的操作,因此,效率很高,这是它在C中被使用的一个主要原因。2. 这种宏定义在形式上类似于一个函数,但在使用它时,仅仅只是做预处理器 阅读全文
posted @ 2013-09-13 10:50 CPYER 阅读(450) 评论(0) 推荐(0) 编辑
摘要: 这是没有引入任何头文件时,如果使用"NULL",编译器会报错:没有定义NULL。此时可用下面代码定义。#undef NULL //#undef 是在后面取消以前定义的宏定义#if defined(__cplusplus) //区别于#ifdef,#if defined的意思是如果在编译这几行之前,已经定义过(&& || && ||)等标识符#define NULL 0 //#define是预处理宏定义命令#else#define NULL ((void *)0)//NULL ((void*)0) C中的“标准”写法,NULL被替换为一个voi 阅读全文
posted @ 2013-09-13 09:23 CPYER 阅读(198) 评论(0) 推荐(0) 编辑