由于研究阶段主要在SLAM方向,因此我也感觉我(孱弱的C++)基础将对我的研究产生不好的影响,因此打算学习C++P PLUS,以后可能要学习数据结构C++版本的。第二章感觉相比谭浩强教科书版本能给我提供的思考点更多,当然第二章还是十分基础的,都能够看明白。
由于未来基本在linux环境下搭建工程,因此稍微了解了一下cmake。在clion上配置文件,由于工程文件不能够支持使用多个main函数,因此需要以下步骤解决。
【解决linux上clion工程下多个main函数的问题】首先新建一个工程文档,把他自带的main删除掉
然后新建一个Cpp文件,这时候直接reload就可以运行。但是有两个cpp文件时,就会存在两个main函数,直接运行是不可以的,需要修改cmakelist
注意cpp文件前面必须不一样,不然相当于两个是同一个下面的cpp,然后点这里选择
最后运行就ok
【变量名设置问题】
这个问题在做书上的第二题的时候发现自己设置了一个变量名long,然后运行不过去,以后还是得多注意啊。
下面贴了一下自己完成的课后代码,刚开始还是比较简单的,希望自己坚持下去,加油!
2.1.cpp
#include "iostream"
//using namespace std;
using std::cout;
using std::endl;
int main()
{
//std::cout<<"QIUF"<<std::endl;
cout<<"QIUF"<<endl;
}
2.2.cpp
#include "iostream"
using namespace std;
int main()
{
int distance;
cin>>distance;
cout<<"码数为 "<<220*distance<<endl;
return 0;
}
2.3.cpp
#include "iostream"
using namespace std;
void pout(void);
void pout2(void);
int main()
{
pout();
pout();
pout2();
return 0;
}
void pout(void)
{
cout<<"Three blind mice"<<endl;
}
void pout2(void)
{
cout<<"See how they ran"<<endl<<"See how they ran";
}
2.5.cpp
#include "iostream"
using namespace std;
int zhuanhua(int);
int main()
{
int she;
cin>>she;
cout<<"Please enter: "<<she<<endl;
int hua;
hua=zhuanhua(she);
cout<<she<<" degree celsius is "<<hua<<" degree huashi";
}
int zhuanhua(int a)
{
int b;
b=1.8*a+32.0;
return b;
}
2.7.cpp
#include "iostream"
using namespace std;
void screen(int a,int b);
int main()
{
int hour;
int minute;
cin>>hour;
cin>>minute;
screen(hour,minute);
}
void screen(int a,int b)
{
cout<<"enter the number of hours: "<<a<<endl;
cout<<"enter the number of hminutes: "<<b;
}
太简单了运行结果就不贴了orz