2017年3月25日

摘要: #include<iostream>using namespace std; int main(){ int *I; //我曾是一个漂泊无放的浪子 int You; //有一天,你出现了 //我终于明白我的归处 for (int j = 10000;;) //我在佛前苦苦求了一万年 { j--; i 阅读全文
posted @ 2017-03-25 11:42 非专业程序员Ping 阅读(258) 评论(0) 推荐(0)

2017年3月20日

摘要: 先上代码: #include<iostream>using namespace std; class A{public: static int a; };int A::a; //必须在类外再次定义,否则要报错int main(){ A a1; A a2; cout << a1.a << endl; 阅读全文
posted @ 2017-03-20 19:19 非专业程序员Ping 阅读(122) 评论(0) 推荐(0)

2017年3月18日

摘要: 一.char和string类型: 1.string类型是对char的封装; 2.string中有单独的函数对诸如strcopy和strlen功能的实现,而且对于string而言,不能用于strlen和strcopy的函数中; 二。strlen和sizeof区别: 1.首先对于strlen来说,单独的 阅读全文
posted @ 2017-03-18 13:55 非专业程序员Ping 阅读(294) 评论(0) 推荐(0)

2017年3月12日

摘要: 1.创建一个顺序文件与文件输入(追加) #include<iostream> #include<fstream> #include<string> using namespace std; int main() { ofstream file; //注意是ofstream而不是ifstream,二者 阅读全文
posted @ 2017-03-12 19:16 非专业程序员Ping 阅读(173) 评论(1) 推荐(0)

2017年3月11日

摘要: 其他: 实例1: template<class type>//模板参数为模板类型参数 type Add(type a, type b) { return a + b; } int main() { //int n = Add<int>(10.5, 20); //int n = Add(10.5, 2 阅读全文
posted @ 2017-03-11 09:44 非专业程序员Ping 阅读(99) 评论(0) 推荐(0)
摘要: 一. 指针 1. int *p = new int(100);//注意()是表示的是指针初始化,即表示p指向100 int *P = new int[3];//这里才是创建了一个数组类似于P[3]; delete[]P; //数组的释放方式 但是书上也说使用delete P释放数组也可以,只是不提倡 阅读全文
posted @ 2017-03-11 09:43 非专业程序员Ping 阅读(108) 评论(0) 推荐(0)
摘要: 一. 类和对象 1.对象和对象指针: Time time, *T; T = &time; time.n = 12; time.show(); T->n = 11; //注意不能使用time->show()的形式,也不能用T.show(); T->show(); 还可以通过new实现实例化 Pen * 阅读全文
posted @ 2017-03-11 09:42 非专业程序员Ping 阅读(117) 评论(0) 推荐(0)
摘要: 一. 动态内存分配 二. 名字空间 number = 10; cout << number << endl; using namespace youname; //好像即使在这里声明了是youname,但是还是不能直接用number = 'Q' youname::number = 'Q'; 阅读全文
posted @ 2017-03-11 09:38 非专业程序员Ping 阅读(94) 评论(0) 推荐(0)
摘要: 二.内联函数 可以加快运行效率,但是会使代码变长 #include<iostream> #include<iomanip> using namespace std; int number; inline int set_number();//内联函数只对编译器请求,故函数声明只能放在外面(解释好像有 阅读全文
posted @ 2017-03-11 09:31 非专业程序员Ping 阅读(91) 评论(0) 推荐(0)
摘要: 一. 关于输入输出格式(iomanip) 1.进制转换: setbase(int n)( cout << setbase(16) << 100 << endl;) 2.字段宽度:setw(右对齐)( cout << setw(10) <<100 << endl;) 3.填充字符:setfill,似乎 阅读全文
posted @ 2017-03-11 09:29 非专业程序员Ping 阅读(110) 评论(0) 推荐(0)

导航