寫一個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~

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章