【发布时间】:2016-11-03 13:45:14
【问题描述】:
// this is the first point class header
class Point : public CWaypoint{
public: //temporarily
string m_description;
public:
Point();
virtual ~Point();
void print();
Point(string name, string description, double latitude, double longitude);
void getAllDataByReference( string& name,string& description, double& latitude,double& longitude);
};
// This is the database class header
class Database
{
private:
Point m_POI[10]; // Point is the other class
int m_noPoi;
public:
Database();
virtual ~Database();
void addPoI(string name,string description,double latitude,double longitude);
Point * getPointerToPoi(string name);
}
【问题讨论】:
-
请在将来为您的代码附上一些文字。
-
具体遇到了什么问题?
-
“如何操作其他类的私有属性”你可能需要公共方法来操作私有属性。
-
您不能操作其他类的私有数据。这就是
private的全部意义所在。如果您想从班级外部操纵成员,请不要将其设为私有。 (嗯,有friend,但这仅适用于特殊情况) -
你为什么不用
std::vector?