C7-Class relationship - © 2004, HOÀNG MINH S Ơ N Ch ươ...

Info iconThis preview shows pages 1–9. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: © 2004, HOÀNG MINH S Ơ N Ch ươ ng 1 K ỹ thu ậ t l ậ p trình 0101010101010101100001 0101010101010101100001 0101010101010101100001 0101010100101010100101 0101010100101010100101 0101010100101010100101 1010011000110010010010 1010011000110010010010 1010011000110010010010 1100101100100010000010 1100101100100010000010 1100101100100010000010 0101010101010101100001 0101010101010101100001 0101010101010101100001 0101010100101010100101 0101010100101010100101 0101010100101010100101 1010011000110010010010 1010011000110010010010 1010011000110010010010 1100101100100010000010 1100101100100010000010 1100101100100010000010 0101010101010101100001 0101010101010101100001 0101010101010101100001 0101010100101010100101 0101010100101010100101 0101010100101010100101 1010011000110010010010 1010011000110010010010 1010011000110010010010 1100101100100010000010 1100101100100010000010 1100101100100010000010 y = A*x + B*u; x = C*x + d*u; StateController start() stop() LQGController start() stop() Ch ươ ng 7: Quan h ệ l ớ p 12/3/2007 2 © 2004, HOÀNG MINH S Ơ N Ch ươ ng 7: Quan h ệ l ớ p © 2007 AC - HUT N ộ i dung ch ươ ng 7 7.1 Quan h ệ l ớ p 7.2 D ẫ n xu ấ t và th ừ a k ế 7.3 Hàm ả o và nguyên lý ₫ a hình/ ₫ a x ạ 7.4 Ví d ụ th ư vi ệ n kh ố i ch ứ c n ă ng 3 © 2004, HOÀNG MINH S Ơ N Ch ươ ng 7: Quan h ệ l ớ p © 2007 AC - HUT 7.1 Phân lo ạ i quan h ệ l ớ p ¡ Ví d ụ minh h ọ a: Các l ớ p bi ể u di ễ n các hình v ẽ trong m ộ t ch ươ ng trình ₫ồ h ọ a — Rectangle — Square — Ellipse — Circle — Line — Polygon — Polyline — Textbox — Group Textbox 4 © 2004, HOÀNG MINH S Ơ N Ch ươ ng 7: Quan h ệ l ớ p © 2007 AC - HUT Bi ể u ₫ồ l ớ p (U nified M odeling L anguage) Quan h ệ d ẫ n xu ấ t Quan h ệ ch ứ a 5 © 2004, HOÀNG MINH S Ơ N Ch ươ ng 7: Quan h ệ l ớ p © 2007 AC - HUT Các d ạ ng quan h ệ l ớ p ( meta model ) Class relationship Association Generalization Dependency Aggregation Composition 6 © 2004, HOÀNG MINH S Ơ N Ch ươ ng 7: Quan h ệ l ớ p © 2007 AC - HUT 7.2 D ẫ n xu ấ t và th ừ a k ế ¡ Ví d ụ xây d ự ng các l ớ p: Rectangle, Square và Textbox (s ử d ụ ng l ớ p Point) L ớ p c ơ s ở L ớ p d ẫ n xu ấ t 7 © 2004, HOÀNG MINH S Ơ N Ch ươ ng 7: Quan h ệ l ớ p © 2007 AC - HUT Th ự c hi ệ n trong C++: L ớ p Point class Point { int X,Y; public: Point() : X(0), Y(0) {} Point(int x, int y): X(x), Y(y) {} int x() const { return X; } int y() const { return Y; } void move(int dx, int dy) { X += dx; Y += dy; } void operator*=(int r) { X *= r; Y *= r; } }; Point operator-(const Point& P1, const Point& P2) { return Point(P2.x()-P1.x(),P2.y()-P1.y()); } 8 © 2004, HOÀNG MINH S Ơ N Ch ươ ng 7: Quan h ệ l ớ p © 2007 AC - HUT Th ự c hi ệ n trong C++: L ớ p Rectangle #include <iostream> #include <string> #include "Point.h" typedef int Color; class Rectangle...
View Full Document

This note was uploaded on 02/05/2012 for the course C++ 101 taught by Professor Abc during the Spring '11 term at Hanoi University of Technology.

Page1 / 33

C7-Class relationship - © 2004, HOÀNG MINH S Ơ N Ch ươ...

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online