C + + programmer learns go basic grammar

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed.

Conceptual differences:

1.Go has no inheritance and virtual functions, but provides interface interface.
2.Go has pointers, but no pointer arithmetic.
3.Go provides garbage collection. No Delete required
A 4.Go string resembles a C + + const char*. Cannot be modified.
5.Go Few types are reference passes.
The external visibility of 6.Go is identified by a case-by-letter definition. In C + + is public,private.
7.Go suppresses implicit type conversions.
8.Go does not support function overloading and operator redefinition.
9.Go uses nil to indicate an invalid pointer.
10. Opening curly brace { must be on the current line.

0. Naming conventions and indentation

1. There is no need for a semicolon at the end of the line ;.

2. The foreign variable or function is capitalized in the first letter.

3. Naming specifications I personally refer to the http://studygolang.com/articles/2059

1. Variables

1. Basic type

var a int8 = 3

var a int16 = 3

var a int32 = 3

var a int64 = 3

var a uint8 = 3

var a uint16 = 3

var a uint32 = 3

var a uint64 = 3

var a float32 = 3

var a float64 = 3

var a int64 = 3

var a int8 = 3

var a int16 = 3

var a int32 = 3

var a int64 = 3

var a string = "ASD"

var a byte = ' V '

2. Enumeration

Const

_ = Iota

A //1

b //2

)

3.type

Type str string

2. Control statements

1.If

If Youcode {

}

2.for

For I:=1; i < x; i++{

No front-facing + + is supported

}

3.switch

Switch (a) {

Case 1:

Case 2:

Default

}

There is no need to break and will return directly.

3. Functions

1.

4. Classes (custom structure) and templates

1.

5. Inheritance

1.

6. Classes, functions, variables referencing other files

1.

7. Interface

1.

8. Arrays

1.

9. Exceptions

1.

10. Concurrency (co-process)

1.


Finally attached:

Package Main
Import(
  "FMT"
)
FuncMain (){
 FMT. Println ("Helloworld!")
}


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.