对象
1. 对象的定义
2. 对象的创建
class Point {
public:
int x;
int y;
void display() {
std::cout << "Point(" << x << ", " << y << ")" << std::endl;
}
};
int main() {
Point p1; // 在栈上创建对象
p1.x = 10;
p1.y = 20;
p1.display(); // 输出:Point(10, 20)
return 0; // p1 自动销毁
}3. 对象的特性
4. 对象的生命周期
5. 对象的复制
6. 对象的比较
7. 总结
Last updated