目前分類:C / Cpp (75)

瀏覽方式: 標題列表 簡短摘要

Operator overloading allows the programmer to define how operators (such as +, -, ==, =, and !) should interact with various data types. 

Because operators in C++ are implemented as functions, operator overloading works very analogously to function overloading.

JerryCheng 發表在 痞客邦 留言(0) 人氣()

Constructor:

Constructors are typically used to initialize member variables of the class to appropriate default values.

JerryCheng 發表在 痞客邦 留言(0) 人氣()

In the class , we can define public or private for its data member (or method).

The data member can only be used by method of class if we define the type of data member is public.

JerryCheng 發表在 痞客邦 留言(0) 人氣()

In C++, classes are very much like structs, except that classes provide much more power and flexibility.

In C++, when we declare a variable of a class, we call it instantiating the class. The variable itself is called an instance of the class. A variable of a class type is also called an object.

JerryCheng 發表在 痞客邦 留言(0) 人氣()

Union is like strucuture but it can only assign one member one time , and a anonymous union is a union without class name .

Anonymous can help us save memory space  , because operation system would allocate the largest memory space of largest

JerryCheng 發表在 痞客邦 留言(0) 人氣()

We can use #define to define a constant or a Marco.

for example: (define a constant)

JerryCheng 發表在 痞客邦 留言(0) 人氣()

A default parameter is a function parameter that has default value.

 

JerryCheng 發表在 痞客邦 留言(0) 人氣()

Reference is a alias of a variable , it can be used to instead of pointer sometimes.

C++ references differ from pointers in several essential ways:

JerryCheng 發表在 痞客邦 留言(0) 人氣()

Sometimes we may generate the functions which have the same function 

but have different argument or return type.

JerryCheng 發表在 痞客邦 留言(0) 人氣()

Arithmetic operators (+ , - , * , \ , %)

Relational and euality operators

JerryCheng 發表在 痞客邦 留言(0) 人氣()

We can use the modifier , setw , to control the width of output.

 

JerryCheng 發表在 痞客邦 留言(0) 人氣()

cout, clog and cerr are pre-defined objects defined in ostream. 

The iostream class inherits from both ostream and istream

JerryCheng 發表在 痞客邦 留言(0) 人氣()

We can use the operator , dec , oct , and hex to decide which format we want.

for example:

JerryCheng 發表在 痞客邦 留言(0) 人氣()

Sometimes , we may want to find word in string.

we can use string::find to achieve this purpose.

JerryCheng 發表在 痞客邦 留言(0) 人氣()

1.Linux下可以使用gdb進行debug

2.bug - segmentation fault

JerryCheng 發表在 痞客邦 留言(0) 人氣()