C++: Hello, World!

# include <iostream>
using namespace std;

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

// 第一個命名空間
namespace first_space{
void func(){
cout << "Inside first_space" << endl;
}
}
// 第一個命名空間
namespace second_space{
void func(){
cout << "Inside second_space" << endl;
}
}
int main ()
{
// 調用第一個命名空間中的函數
first_space::func();

// 調用第一個命名空間中的函數
second_space::func();

return 0;
}
Inside first_space
Inside second_space
int main(){
cout << "Hello, World! \n";
return 0;
}
  1. printf(): 跟 C 語言中的 printf() 寫法相同,Syntax 如下:
printf(value_to_print);
cout<<value_to_print<<value_to_print;
  • \n (new line): 換行
  • \t (Tab): 等同於Tab鍵

--

--

生無大志,好想當米蟲。

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store