Posted 2019-05-18Updated 2022-07-04Learning-Note-學習筆記a few seconds read (About 90 words)物件指標 (Object Pointer)物件指標 教學與筆記。 說明將類別宣告物件指標並指向某個物件,可使用 -> 運算子存取該物件的屬性和方法。 完整程式碼12345678910111213141516171819202122232425#include <iostream>using namespace std;class Car { private: int _speed; public: void SetSpeed(int speed) { _speed = speed; } int GetSpeed() { return _speed; }};int main() { Car MyCar; Car *ptr = &MyCar; ptr->SetSpeed(200); cout << ptr->GetSpeed() << endl; system("PAUSE"); return 0;}物件指標 (Object Pointer)https://meowlucian.github.io/C++/OOP/Object-Pointer/AuthorMeow LucianPosted on2019-05-18Updated on2022-07-04Licensed under#CodeC++