mon678 48 Report post Posted March 9, 2010 nk minta tolong terangkan mcm mane nk gune accesor untuk access data private dlm class tue conth:- Class X{ private: int w; int u; public: print()const; }; mcm nk print out data private tue dlm function print()const tue? Quote Share this post Link to post Share on other sites
khairiez 0 Report post Posted March 14, 2010 accessor nie bermaksud apabila sesuatu "member function" nie yg dpt value dr "class memmber" tetapi nilainye x berubah... 2 la accessor.. contoh:- [code] class rectangle { private: double width; double length; public: void setWidth(double); void setLength(double); double getWidth() const; double getLength() const; double getArea() const; }; [/code] "member function" getlength dan getWidth 2 la accessors.. kalau nak print out plak... [code] double rectangle::getWidth() const { return width; } [/code] make sure value da pass dlm function main.. Quote Share this post Link to post Share on other sites
mon678 48 Report post Posted March 14, 2010 kalau kt public tue ade function void print()const...mcm mane nk gune accessor tue dlm function print tue? Quote Share this post Link to post Share on other sites