#include <iostream>
class SomeClass
{
public: int *SomeNumber;
SomeClass() { SomeNumber = new int; *SomeNumber = 5; }
~SomeClass() { delete SomeNumber; }
int getSomeNumber(void) { return *SomeNumber; }
};
int main()
{
SomeClass A;
std:: cout << A.getSomeNumber() << std::endl; // outputs 5
std:: cout << A.SomeNumber << std::endl; // outputs SomeNumber address
return 0;
}
我如何不使用这种方法获得SomeNumber(SomeNumber)而不是地址? 如果一些Number不是墨水的点子,我可以带A.SomeNumber。
Sorry If I were not clear enough. Thanks in advance.