C++学习笔记1,hello word!、有无using nameSpace std的区别,一闪而过的注意事项

一闪而过的注意事项
有的用的编译器运行后会一闪而过,在return 0;上面加一句system(“pause”);

无using nameSpace std

#include <iostream>

int main() {
   std:: cout << "Hello, World" << "!" << std::endl;
   // system("pause");
    return 0;
}

有using nameSpace std

#include <iostream>
using namespace std;

int main() {
    cout << "Hello, World" << "!" << endl;
   // system("pause");
    return 0;
}

详细解读:

//标准的输入输出流  in输入 out输出
#include <iostream>

//使用命名空间std打开一个std房间
using namespace std;

//函数入口
int main() {

    //cout 标准的输出
    //<<左移运算符,评接作用
    //endl结束换行
    cout << "Hello, World" << "!" << endl;

    //阻塞有些编译软件编译后会一闪而过
   // system("pause");
    return 0;
}

运行结果:
运行结果

原创文章 44 获赞 8 访问量 3888

猜你喜欢

转载自blog.csdn.net/weixin_44692299/article/details/104275900
今日推荐