C++学习日记
Whity_Yuan
这个作者很懒,什么都没留下…
展开
-
关于输入
cin读取输入流,遇到空格,回车,制表符结束读取,并忽略空格和换行符。cin对象在接收到错误类型时会返回false,可通过cin.fail()和cin.eof() EOF 是否被设置为1. 当cin将队列读到int型变量时,遇到非数字字符停止;double型--遇到第一个不属于浮点数的字符停止;char数组类型--遇到空白字符停止。int n;cin>>n; //will retru...原创 2018-03-22 18:32:27 · 180 阅读 · 0 评论 -
【C++错误】:R6010 -abort() has been called
出现这个错误可能的原因是 点击打开链接而我在处理云点时,问题出在指针,刚开始我只通过pcl::PointIndices::Ptr inliers定义了inliers, 而没有为它开辟空间,因此在seg.segment函数中进行传参时,指针出现问题。所以,要注意通过函数传参返回运算结果时,一定要先开辟好存储空间,在存储。int Ransac::PlaneEstimation(pcl::PointCl...原创 2018-06-16 18:43:06 · 1468 阅读 · 0 评论 -
Mac下Xcode(C++)+OpenCV环境配置
https://medium.com/@jaskaranvirdi/setting-up-opencv-and-c-development-environment-in-xcode-b6027728003转载 2018-05-28 17:31:24 · 950 阅读 · 0 评论 -
使用ofstream和ifstream
头文件iostream预先定义了一个名为cout的ostream对象, 而要使用ofstream需要用户自己声明一个对象。这个对象和cout的用法非常相似,只是cout将结果打印到屏幕上,ofstream的对象将结果写到文件里。ofstream outFile;outFile.open("example.txt"); //associate with a fileoutFile<<...原创 2018-03-24 04:43:54 · 217 阅读 · 0 评论 -
指针
int a = 12;int *p;p = &a;注意:p表示指针地址,*p是该地址内所存储的值。当定义一个指针时, 计算机将只分配用来存储地址的内存,但不会分配用来存储指针所指向数据的内存。比如,以下代码就是错误的。long *pl;*pl = 123456;//place a value in never-never land, to which the pointer pl d...原创 2018-03-23 03:34:43 · 144 阅读 · 0 评论 -
枚举
枚举类型可以将一个类型限制在可控制的范围内。比如枚举星期,颜色等。示例代码: enum spectrum {red, orange, yellow, gree, blue, violet, indigo}; spectrum color; //declare a variable of enum type color = blue; cout << color << ...原创 2018-03-23 01:53:02 · 195 阅读 · 0 评论 -
共用体和结构体的区别
结构体可以同时存储多种变量类型,而共同体同一个时间只能存储和使用多个变量类型的一种,当另一时间,变量类型被改变后,原来的变量类型和值将被舍弃。共用体的作用是同一个数据项可以使用多种格式,可以节省空间。比如,对商品进行标识时可以用整数和字符串中的一个。struct product{ int type; int amount; union id { long id_long; cha...原创 2018-03-23 01:17:04 · 9013 阅读 · 0 评论 -
string类简介
赋值,拼接和附加string s1 = "string1";string s2 = "string2";string s3;s3 = s1 + s2;s1 += s2;s2 +="add something";头文件cstring提供的函数char charr1[20];char charr2[20]'strcpy(charr1, charr2); //copy charr2 t...原创 2018-03-22 18:57:06 · 305 阅读 · 0 评论