写一个C++风格的hello world

整理时间:2020-05-30
目录
1. C风格的hello world
2. C++风格的hello world
3. 总结

正文
1. C风格的hello world

#include <stdio.h>

int main()
{
	printf("Hello, world!\n");
	return 0;
}

2. C++风格的hello world

(1)example 1

#include <iostream>
//using namespace std;
int main()
{
	std::cout << "Hello, world!" << "\n";
	std::cout << "Hello, world!" << std::endl;
	return 0;
}

(2)example 2

#include <iostream>
using namespace std;
int main()
{
	cout << "Hello, world!" << "\n";
	cout << "Hello, world!" << endl;
	return 0;
}

3. 总结

C++比C语言多的新概念
namespace
iostream
endl


THE END~

猜你喜欢

转载自blog.csdn.net/hahahahhahha/article/details/106438956