流云の剑舞秋风

吾生也有涯 而知也无涯

博客园 首页 新随笔 联系 订阅 管理

随笔分类 -  C++

基础知识
摘要:#include #include voidmain() { charSourceName[81]; charDestinName[81]; cout>SourceName; cout>DestinName; try { CFilefileSource(SourceName,CFile::modeRead); ... 阅读全文
posted @ 2005-05-13 19:56 流云 阅读(1602) 评论(1) 推荐(0)

摘要://读写2进制流文件 #include #include #include voidmain() { ofstreamf1("wr1.dat"); if(!f1) { cerr>x) cout<<x<<''; cout<<endl; f2.close(); } 阅读全文
posted @ 2005-05-13 19:54 流云 阅读(589) 评论(0) 推荐(0)

摘要:c++中创建动态二维数组的程序代码 动态创建一维数组 int*arr;//itcanbeanyothertype(char,float) arr=newint[n];//nshouldbeintegervariable 动态创建二维数组 int**arr; intN,M; cin>>N>>M; arr=newint*... 阅读全文
posted @ 2005-05-12 16:17 流云 阅读(1241) 评论(0) 推荐(0)

摘要:#include #include #include voidmain() { srand((unsigned)time(NULL));//以系统时间作种子,就不会每次都产生一样的序列了 doubletemp=double(rand()%4000+3000)/10000.0;//调节精度 temp=temp<0.5?(temp-0.2):(... 阅读全文
posted @ 2005-05-12 09:42 流云 阅读(535) 评论(0) 推荐(0)

摘要:全局变量的定义一直不知道怎么弄,困绕很久,终于在vckbase之阿荣的BLOG上找到答案了 http://blog.vckbase.com/arong/archive/2004/05/28/294.aspx 简述如下:工程中有xx.cpp,yy.cppxx.h,yy.h等,在xx.cpp里的函数外部分定义变量int test=5;为了在yy.cpp里使用刚刚定义的tes... 阅读全文
posted @ 2005-05-08 23:04 流云 阅读(769) 评论(0) 推荐(0)

摘要:①对于一般常量,const在类型说明符的前面或者后面,都是一样的.eg: const int i=9; int const i=9; ②使用const修饰指针时,会由于const位置不同而含义不同. eg: char * const p=str1;p为常量指针,p的指向不可以变,而*p可更新,即语句p=str2 非法,语句*p="C"正确. const char * p=str1;p... 阅读全文
posted @ 2005-05-08 23:00 流云 阅读(491) 评论(0) 推荐(0)

摘要:C允两者不一致,而C++则不允许. //...... void *f; int i=1,*p; f=&i; p=(int*)f; f=p; cout<<"p is "<<p<<*p; cout<<"f is "<<f<<*f; // void... 阅读全文
posted @ 2005-05-08 22:57 流云 阅读(399) 评论(0) 推荐(0)

摘要:1.new 用法:指向对应类型的指针=new 类型描述符 a. 一个机器字长 int *p; p=new int; b. 一个机器字长,并赋值 int *p; p=new int(20); c. 多个字长,按数组或指针引用 int *p; p=new int [20]; 2.delete 用法:delete 指针名 指针是数组... 阅读全文
posted @ 2005-05-08 22:56 流云 阅读(328) 评论(0) 推荐(0)

摘要:类的构造函数 阅读全文
posted @ 2005-05-08 22:54 流云 阅读(398) 评论(0) 推荐(0)

摘要:成员初始化 阅读全文
posted @ 2005-05-08 22:54 流云 阅读(309) 评论(0) 推荐(0)

摘要:1#include 2#include 3inttemp,m[30][30]={0,}; 4voidHelix(intmin,intmax) 5{ 6for(inti=min;i>N; 22if(N30) 23break; 24max=N-1; 25temp=1... 阅读全文
posted @ 2005-05-08 17:00 流云 阅读(685) 评论(0) 推荐(0)