面向对象程序设计

课程名称:面向对象程序设计

授课教师:霍宇驰

好像是计院必修课程吧,提前一学期在大二秋冬学期就选上了这门课,希望本学期不会死掉。

Introduction

The C language

  • Strengths
    • Efficient programs
    • Direct access to machine, suitable for OS and ES
    • Flexible
  • Weakness
    • Insufficient type checking
    • Unsuitable for high-level applications
    • No direct support for oop

C++ improvements

  • References
  • Operator overloading
  • Data abstraction
  • Access control

Using Objects

Like the string class

1
2
3
4
5
6
7
#include<string>

string name = "Alice"

cout<<name;

string anotherName = name;

File I/O

1
2
3
4
5
6
#include<ifstream>
#inclued<ofstream>
int main(){
ofstream File1("C:\\test.txt");
...
}

Pointers to Objects

1
2
3
4
string s = "hello";
string *ps = &s;
(*ps).length();//*: get the object
ps->length()//->: call the function

Reference

1
2
3
4
5
6
7
int x;
int &y=x;
y=5;//change the value of x
int f(int &z){
z=3;
}
f(x)//change the value of x

面向对象程序设计
http://example.com/2024/09/12/OOP/
作者
Penner
发布于
2024年9月12日
许可协议