Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 34 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
34
Dung lượng
254 KB
Nội dung
Lập trình hướng đối tượng Bài 3: Đối tượng lớp Nội dung Đối tượng Lớp Phép gán đối tượng Thiết lập hủy bỏ Dữ liệu hàm tĩnh Hằng số Hàm bạn lớp bạn Đối tượng Object = Data + Method Point object { // data int x,y; //method void init (int ox, int oy); void move (int dx, int dy); void display(); }; Lớp Khai báo lớp class { private: public: }; #include #include class point{ private: int x,y; public: void init(int ox, int oy); void move(int dx, int dy); void display(); }; // Define component function outside declaration void point::init(int ox, int oy){ cout[...]... ” ... b=fct(a); b.display(); } 21 Thiết lập copy Create object: 0xfff2 Two parameters constructor Coordinate: Create object: 0xffea Copy constructor Create object: 0xffde Copy constructor Create object: 0xffee... members of both class A & B } 33 Tất hàm thành phần lớp bạn lớp kh c class B; class A{ friend class B; }; class B{ // Member functions of class B can access to private member of class A }; 34... init function display function coordinate: move function display function coordinate: 6 Lớp Tạo đối tượng ; Data frame Object Data of object Object Data of object Lớp