; [2] ; [3] , Smalltalk Lisp. : (, ), (, ). , . , , , , ++, . , () , , ++. , , , . , , , , , , ++ . $$12.1.4 ++ "-". 12.1.1  - . ++ -, , , , , . , , . . , , . , (, ). , , , , , , , . , ( ), , , , CASE, - ( ) . , , , . , , , , . , . , , . ( ) . , . , . ++ , , . , . . , . , . 1 , . " ++ , ?" , , , , ++ . , , , ( ++ ), , , ++. - - . , : , , . - ? , . , - , - , - - . , "" , , , , , . , "" "" , . , "" . , , . , . , . "-" , - . , , . , , . , , . 12.1.2  2 - , . ++, ++ , , , .. , , , " - ", " ", " ". - , . , . ++, , . , , , " ". , , , , . , , " " , "" . . , , , , , ++, . , " " , , . , . , , , . , , , . 12.1.3  3, , . , " - ", " , ", " ". , . , , . , , , , . . , . ++ . , , . . , , . , . : , . : , , , . . , . , . , , . . " ", , () . : , . , . . : " "; , : " ?", " ?", " ?" " " . (, , ), . $$11.3.3 2 (, 1) 4. - ++, , ( ) . . , , , ++. , "", . , , : " f() , " ( ), " f() , " ( ). , .. . $$1.5.2. , , . , 3 10 . . . , . , , . $$12.4. , , , , , ++. , , ++ , , . : class X { // pseudo code, not C++ f() g() } class Y { g() h() } class Z { h() f() } : k(a, b, c) // pseudo code, not C++ { a.f() b.g() c.h() } X x Y y Z z k(x,y,z) // ok k(z,x,y) // ok , k() , f(), - g(), - h(). k(y,x,z); // fail k(x,z,y); // fail . (, Smalltalk CLOS), ++ , , . , , ++, , . , , : class F { virtual void f(); }; class G { virtual void g(); }; class H { virtual void h(); }; class X : public virtual F, public virtual G { void f(); void g(); }; class Y : public virtual G, public virtual H { void g(); void h(); }; class Z : public virtual H, public virtual F { void h(); void f(); }; k(const F& a, const G& b, const H& c) { a.f(); b.g(); c.h(); } main() { X x; Y y; Z z; k(x,y,z); // ok k(z,x,y); // ok k(y,x,z); // error F required for first argument k(x,z,y); // error G required for second argument } , k() , . , , , ++ , . , . . , , , . , , , . 12.1.4  . . , " " " " . , , . ++ . , ++ , - - , , . , , . : - . - . - ( ). - . - , , . , . . ++ , , : - ++, . - , , ++ . - , ++, , . - , . ++: ++ , , , , - . , , , , ++. , ++, ++ , , - , , . , - . , math ++ : extern "C" { #include <math.h> } , . , , ++ , . , , ++. , , , , ++. $$7.6. , . . , int : class Int : public My_object { int i; public: // definition of operations // see exercises [8]-[11] in section 7.14 for ideas // [8]-[11] // 7.14 }; , . , ++ . : class myclass { // representation public: void f(); T1 g(T2); // ... }; extern "C" { // map myclass into C callable functions: void myclass_f(myclass* p) { p->f(); } T1 myclass_g(myclass* p, T2 a) { return p->g(a); } // ... }; - : // in C header file extern void myclass_f(struct myclass*); extern T1 myclass_g(struct myclass*, T2); ++, , , , , , . 12.2  - , . , , . . : - , - , - - . , . $$12.4 , . , , , . , ++ , . 12.2.1 ? : [1] , , .. , ; [2] , , .. , . , , . , , . , , , , . , . : [1] , (, ), [2] , ( ), [3] , (, ), [4] , (, ), [5] , (, , , ) [6] . . : [1+2] , [3+4] , , [5+6] ( ) . , , . , . , , [1] , [2] , [3] , [4] , ; [5] . , . , , . , " , , 5000 , 13 " - . - - . . . , . , "", "" "". , , , . (, , ) , . , () , "" , . . , , , , , . : "" , - . , . , , . , . , - . . 12.2.2  , , , . , , , , .. , , . , . , , . , , . . . , , , , , , . : Emergency , , : , , .. ++ : class Vehicle { /*...*/ }; class Emergency { /* */ }; class Car : public Vehicle { /*...*/ }; class Truck : public Vehicle { /*...*/ }; class Police_car : public Car , public Emergency { //... }; class Ambulance : public Car , public Emergency { //... }; class Fire_engine : public Truck , Emergency { //... }; class Hook_and_ladder : public Fire_engine { //... }; - , ++ . : . : , . , Emergency Vehicle: (Vehicle {eptr}) (Car) (Truck) (Police_car) (Ambulance) (Fire_engine) (Hook_and_ladder) Emergency , : class Emergency { /*...*/ }; class Vehicle { public: Emergency* eptr; /*...*/ }; class Car : public Vehicle { /*...*/ }; class Truck : public Vehicle { /*...*/ }; class Police_car : public Car { /*...*/ }; class Ambulance : public Car { /*...*/ }; class Fire_engine : public Truck { /*...*/ }; class Hook_and_ladder : public Fire_engine { /*...*/ }; , Vehicle::eptr . "" Vehicle::eptr , Vehicle::eptr , : Car::Car() // Car { eptr = 0; } Police_car::Police_car() // Police_car { eptr = new Emergency; } : void f(Vehicle* p) { delete p->eptr; p->eptr = 0; // //... p->eptr = new Emergency; // } ? : " , ". , "", , . , , . - , , . , - , . , , , , , , . , , , . $$12.2.5, (scrollbar) - . 12.2.3 . , . , . : " , ." , , , . , . , , . : class B { //... protected: int a; public: virtual int f(); int g() { int x = f(); return x-a; } }; g()? f() . , g() 1: class D1 : public B { int f() { return a+1; } }; g() "Hello, World" 0: class D1 : public { int f() { cout<<"Hello, World\n"; return a; } }; , . , , . , , , , . , , , . , , . , rotate() Shape , rotate() , , Circle Triangle, , Shape. B D1 D2 , . . ( ) ? , , . , , , , , . , , ( ) , , . , : template<class T> class buffer { // ... void put(T); T get(); }; , "" , . put() get() overflow() underflow() , , , : template<class T> class buffer { //... virtual int overflow(T); virtual int underflow();