随记2018_12_29
类定义是一条C++语句,因此必须用分号结束
:: 作用域解析运算符
类的方法可以访问对象所属类中所有的数据成员
智能指针:使用智能指针时,不需要手动释放内存,内存会自动释放
堆栈中的对象:
下面的代码在堆栈中创建并使用了SpreadsheetCell对象
SpreadsheetCell myCell, anotherCell;
myCell.setValue(6);
anotherCell.setString("3.2");
堆中的对象:
使用new动态分配对象:如果用new为某个对象分配了内存,结束的时候要用delete
SpreadsheetCell* myCellp = new SpreadsheetCell();
myCell -> setValue(3.7);
delete myCellp;
myCellp = nullptr;