上一页 1 ··· 120 121 122 123 124 125 126 127 128 ··· 133 下一页
摘要: class Base { public: void do(){} } class Son:public Base { public: void do(){}//覆盖 } 1、虚函数 父类和子类都有一个方法:do();但是通过子类对象指针访问这个do方法的时候,编译器会选择基类的do()来实现,而不是 阅读全文
posted @ 2016-09-19 15:49 朱小勇 阅读(235) 评论(0) 推荐(0)
摘要: int a=1234; int current; while(a) { current=a%10;//4 cout<<current; a=a/10; } 阅读全文
posted @ 2016-09-19 10:51 朱小勇 阅读(1376) 评论(2) 推荐(0)
摘要: 1、Typedef 为一个已知数据类型自定义一个别名。 如 Typedef int* intpointer; 2、#define 做一个简单的替换工作,代码编写时不会对错误进行检查 注意:define是定义常量,typedef是定义变量 阅读全文
posted @ 2016-09-19 10:01 朱小勇 阅读(141) 评论(0) 推荐(0)
摘要: 1、 枚举就是定义一个集合,编译器给每个集合赋值,从0开始。 enum weeks{monday,tuesday}; weeks week; week=monday; //此时week==0。 2、 enum CUSTOMPLOT_DATA_TYPE{ PANTOGRAPH_DATA = 1,//受 阅读全文
posted @ 2016-09-19 09:56 朱小勇 阅读(177) 评论(0) 推荐(0)
摘要: 联合样子和结构体长得一样,但是结构体可以存储里面所有数据,而联合只能存储其中一个数据: union Code{ std::string first; std::string sec; }; main() { Code code; code.first=“”12345“”; code.sec="543 阅读全文
posted @ 2016-09-19 09:53 朱小勇 阅读(169) 评论(0) 推荐(0)
摘要: 所谓namespace,是指标识符的各种可见范围。 C++标准程序库中的所有标识符都被定义于一个名为std的namespace中,这样命名空间std内定义的所有标识符都有效。 为什么把cout等放在std里,是因为用户会多次使用cout等,防止此对象被使用多次。 <iostream>和<iostre 阅读全文
posted @ 2016-09-18 21:15 朱小勇 阅读(354) 评论(0) 推荐(0)
摘要: sprintf(); #include <stdio.h> void put_int_with_space(int v) { char str[50]; //定义一个足够大的数组。 int i; sprintf(str, "%d", v); //将v转为字符串。 } 阅读全文
posted @ 2016-09-18 17:16 朱小勇 阅读(2562) 评论(0) 推荐(0)
摘要: CString FileName; CFileDialog dlg(TRUE);//TRUE是OPEN对话框,FALSE是SAVA AS对话框 if(dlg.DoModal()==IDOK) FilaName==dlg.GetPathName();//GetPathName获取绝对路径;GetFil 阅读全文
posted @ 2016-09-18 15:35 朱小勇 阅读(168) 评论(0) 推荐(0)
摘要: #ifndef XXX //如果没有定义XXX #define XXX//那就定义 class Point{ //定义一个Point类 } #endif //结束定义 #ifndef XXX //同理 #define XXX class Point{ } #endif 这样是为了避免重复定义poin 阅读全文
posted @ 2016-09-14 14:07 朱小勇 阅读(139) 评论(0) 推荐(0)
摘要: 实际上就是一个变量的别名,指向同一个地址。 如:int a=0; int &b=a; b=1;//a就=1了 和指针变量的区别:指针需要空间,引用不需要空间。 阅读全文
posted @ 2016-09-14 13:59 朱小勇 阅读(155) 评论(0) 推荐(0)
上一页 1 ··· 120 121 122 123 124 125 126 127 128 ··· 133 下一页