Tổng hợp tài liệu, ebook Kỹ Thuật Lập Trình tham khảo.
By default, use a vector You need a reason not to You can “grow” a vector (e.g., using push_back()) You can insert() and erase() in a vector Vector elements are compactly stored and contiguous For small vectors of small elements all operations are fast compared to lists If you don’t want elements to move, use a list You can “grow” a list (e...
43 trang | Chia sẻ: nguyenlam99 | Ngày: 04/01/2019 | Lượt xem: 1015 | Lượt tải: 0
An introduction to the STL, the containers and algorithms part of the C++ standard library. Here we’ll meet sequences, iterators, and containers (such as vector, list, and map). The algorithms include find(), find_if(), sort(), copy(), copy_if(), and accumulate().
43 trang | Chia sẻ: nguyenlam99 | Ngày: 04/01/2019 | Lượt xem: 958 | Lượt tải: 1
We’ll see how we can change vector’s implementation to better allow for changes in the number of elements. Then we’ll modify vector to take elements of an arbitrary type and add range checking. That’ll imply looking at templates and revisiting exceptions.
38 trang | Chia sẻ: nguyenlam99 | Ngày: 04/01/2019 | Lượt xem: 957 | Lượt tải: 0
Think of a reference as an automatically dereferenced pointer Or as “an alternative name for an object” A reference must be initialized The value of a reference cannot be changed after initialization int x = 7; int y = 8; int* p = &x; *p = 9; p = &y; // ok int& r = x; x = 10; r = &y; // error (and so is all other attempts to change what r ...
35 trang | Chia sẻ: nguyenlam99 | Ngày: 04/01/2019 | Lượt xem: 899 | Lượt tải: 0
The next three lectures will show how the standard vector is implemented using basic low-level language facilities. This is where we really get down to the hardware and work our way back up to a more comfortable and productive level of programming.
32 trang | Chia sẻ: nguyenlam99 | Ngày: 04/01/2019 | Lượt xem: 944 | Lượt tải: 0
Graphical user interfaces Windows and Widgets Buttons and dialog boxes
50 trang | Chia sẻ: nguyenlam99 | Ngày: 04/01/2019 | Lượt xem: 956 | Lượt tải: 0
To override a virtual function, you need A virtual function Exactly the same name Exactly the same type struct B { void f1(); // not virtual virtual void f2(char); virtual void f3(char) const; virtual void f4(int); };
33 trang | Chia sẻ: nguyenlam99 | Ngày: 04/01/2019 | Lượt xem: 936 | Lượt tải: 0
Simple_window win20(pt,600,400,"16*16 color matrix");
Vector_ref
33 trang | Chia sẻ: nguyenlam99 | Ngày: 04/01/2019 | Lượt xem: 934 | Lượt tải: 0
Circle c(Point(100,200),50); // center, radius Ellipse e(Point(100,200), 75,25); // center, horizontal radius, vertical radius e.set_color(Color::dark_red); Mark m(Point(100,200),'x'); ostringstream oss; oss << "screen size: " << x_max() << "*" << y_max() << "; window size: " << win.x_max() << "*" << win.y_max(); Text sizes(Point(100...
45 trang | Chia sẻ: nguyenlam99 | Ngày: 04/01/2019 | Lượt xem: 884 | Lượt tải: 0
Binary literals 0b1010100100000011 Digit separators 0b1010'1001'0000'0011 Can also be used for for decimal, octal, and hexadecimal numbers User-Defined Literals (UDLs) in the standard library Time: 2h+10m+12s+123ms+3456ns Complex: 2+4i
28 trang | Chia sẻ: nguyenlam99 | Ngày: 04/01/2019 | Lượt xem: 908 | Lượt tải: 0