helloWorld.

 从Hello,world! 开始吧。

 

 C++ Golang 
1 #include <iostream>
2 
3 int main()
4 {
5     std::cout << "Hello,world!" << std::endl;
6     return 0;
7 }

 

 
1 package main
2 
3 import (
4     "fmt"
5 )
6 
7 func main() {
8     fmt.Println("Hello,world!")
9 }

 

双冒号前面的 "std" 是标准函数库所在的namespace名字,

可以先使用using语句,这样使用标准函数库的任何对象可省掉该前缀。

 

1 #include <iostream>
2 
3 using namespace std;
4 
5 int main()
6 {
7     cout << "Hello,world!" << endl;
8     return 0;
9 }

 

import "fmt" 中的"fmt"是package fmt所在的目录名称。

不过,目录名通常和包名一致。

在import时加上点号,在使用时可以省掉package前缀。

1 package main
2 
3 import (
4     . "fmt"
5 )
6 
7 func main() {
8     Println("Hello,world!")
9 }

 

   

 

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
posted @ 2020-05-02 15:16  余力出奇迹  阅读(128)  评论(0)    收藏  举报