随笔分类 -  c++ primer plus note

摘要:void test(int & val); void test2(const int & val); void test3(int val); struct Person{ string name; int age; int weight; }; int main() { int rats = 10; int & rodents = rats; ... 阅读全文
posted @ 2017-12-12 09:16 我是外婆 阅读(139) 评论(0) 推荐(0)
摘要:char *p; // 不以空字符结尾的只能是字符数组 char str[] = {'a', 'b', 'c', 'd', 'e'}; char str1[] = {'a', 'b', 'c', 'd', 'e', '\0'}; cout << str1 << endl; char str2[] = "sdfsdfsdfwerwetrwerfsd";... 阅读全文
posted @ 2017-12-10 16:03 我是外婆 阅读(102) 评论(0) 推荐(0)
摘要:int *p = new int; cout <<"p` address :" << p << endl; *p = 123; delete p; // int *p2 = 123; int *p1 = {1, 2, 3, 4, 6}; //以上形式是错误的,计算机只会分配指针占用的内存,但是不会初始化 右边数据的内存 //... 阅读全文
posted @ 2017-12-08 11:43 我是外婆 阅读(186) 评论(0) 推荐(0)
摘要:string str = "sdfsdfsd1234fsdf"; cout << str.size() << endl; cout << str.insert(str.size(), "123") << endl; cout << str.find("123") << endl; cout << str.substr(0, 4) << endl; cou... 阅读全文
posted @ 2017-12-08 10:46 我是外婆 阅读(81) 评论(0) 推荐(0)
摘要:char str[] = "123"; // strlen 只计算可见字符, sizeof 则包含'\0' 在内 cout << "strlen : " << strlen(str) << endl; cout << "sizeof :" << sizeof(str) << endl; char name[10]; char name1[10]; ... 阅读全文
posted @ 2017-12-08 09:52 我是外婆 阅读(105) 评论(0) 推荐(0)