1:g++ 和gcc 版本都是 4.4,比较老,在C++ 程序中包含头文件的时候要include<iostream>,不能include<iostream.h>,并且一定要指明标准域间即 :using namespace std;
不然找不到对应的头文件或者显示 cout cin 等没有声明.
2: vim 命令模式下 :set number 可以显示行号(左边)
3: mv file newfilename 来重命名文件
4:namespace 就是限定作用域,设定一个域,在该域中设定你的函数或者变量,防止撞车。
用法:
namespace firstNamespce
{
void speak() {cout<<"Hello man!"}
namespace secondNamespace
{
void speak{cout<<"Hello woman!"}
}
}
在文件前面using namespace std;后定义即可
#include<iostream>
using namespace std;
namespace firstNamespce
{
void speak() {cout<<"Hello man!"}
namespace secondNamespace
{
void speak{cout<<"Hello woman!"}
}
}
using namespace firstNamespace;void main()
{
speak();
secondNamespace::speak();
}
5:#pragma once 也是只要程序只编译一次,和#ifndef
#define
.........
#endif
相同的作用