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: 948 | 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: 986 | 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: 1001 | 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: 977 | 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: 982 | 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: 931 | 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: 954 | Lượt tải: 0
What logical parts do we what? int get_int(int low, int high); // read an int in [low.high] from cin int get_int(); // read an int from cin // so that we can check the range int void skip_to_int(); // we found some “garbage” character // so skip until we find an int Separate functions that do the logically separate actions
35 trang | Chia sẻ: nguyenlam99 | Ngày: 04/01/2019 | Lượt xem: 1002 | Lượt tải: 0
Essential operations Default constructor (defaults to: nothing) No default if any other constructor is declared Copy constructor (defaults to: copy the member) Copy assignment (defaults to: copy the members) Destructor (defaults to: nothing) For example Date d; // error: no default constructor Date d2 = d; // ok: copy initialized (copy the ...
31 trang | Chia sẻ: nguyenlam99 | Ngày: 04/01/2019 | Lượt xem: 974 | Lượt tải: 0
A namespace is a named scope The :: syntax is used to specify which namespace you are using and which (of many possible) objects of the same name you are referring to For example, cout is in namespace std, you could write: std::cout << "Please enter stuff \n";
33 trang | Chia sẻ: nguyenlam99 | Ngày: 04/01/2019 | Lượt xem: 981 | Lượt tải: 0