P
penny336
dear all,
just a little confused in c++ oop , in the below class, i set x,y as
private, but it can be accessed directly in copy constructor e.g x=p.x
is it problems in c++?
//=== file Point.h =============================================
class Point {
public:
Point(const Point& p); // copy constructor private: int x,
y;};//=== file Point.cpp ==========================================
.. . .
Point:oint(const Point& p) {
x = p.x;
y = p.y;
}
just a little confused in c++ oop , in the below class, i set x,y as
private, but it can be accessed directly in copy constructor e.g x=p.x
is it problems in c++?
//=== file Point.h =============================================
class Point {
public:
Point(const Point& p); // copy constructor private: int x,
y;};//=== file Point.cpp ==========================================
.. . .
Point:oint(const Point& p) {
x = p.x;
y = p.y;
}