1. 程式人生 > >C++ Study Note(1)

C++ Study Note(1)

1 Chapter - Preparing Knowledge

  • Generic Programming(泛型程式設計)
  • Object Oriented Programming(面對物件程式設計)

data + method = program

C C++
procedural language object oriented language
stress algorithm stress data
top-down bottom-top

2 Chapter - Start to Learn C++

2.1 main()

int main()
{
	statements;
return 0; }

2.2 C++ Preprocesser and Iostream Headfile

#include <iostream>//將iostream檔案的內容新增到程式中,然後再和原始碼一起編譯
using namespace std;//簡化程式,保證可以使用輸入輸出工具

2.3 Namespace

If you use iostream instead of iostream.h, you need add using compliling command to make iostream definition avalible

using namespace std;
//using 編譯指令,使得std名稱空間中的所有名稱都可用
// 用到哪個名稱就使哪個名稱可用
using std::cout;
using std::endl;
using std::cin;

2.4 Use cout to Output

cout trait function
predefine object(預定義物件) << insert right information to ostream
endl trait function
manipulater(控制符) none start a new line
cin trait function
predefine object(預定義物件) >> take proper value from istream to right variable

2.5 Class Introduction

Class decribe one data type’s all properties(including its operating method) Object is a real thing launched by class description

Use special object to execute special operation(send message to object)

  1. Use class method
  2. Operator overloading ( cin and cout )

Summary

C++ has six types case:

  1. declaration case(宣告語句)
  2. evaluation case(賦值語句)
  3. message case(訊息語句)
  4. function invoking case(函式呼叫)
  5. function prototype case(函式原型)
  6. return case(返回語句)