void f(int, double); void f(double, int); f(1,2.0);f(int, double);
f(2.0,1);f(double,int);
f(1,1);error: ambiguous
class P; class C; void f(P* p) { cout << "f(P*)"; }\c{// (1)}
void f(C* c) { cout << "f(C*)"; }\c{// (2)}
class P { public: virtual void f() { cout << "P::f"; }\c{// (3)}
}; class C : public P { public: virtual void f() { cout << "C::f"; }\c{// (4)}
};
P* p = new P;static and dynamic
C* c = new C;P* static and dynamic
P* pc = new C;C* stat\c{ic}
f(p);P* , dyna\c{mic}C* f(P*)
f(c);f(C*)
f(pc);f(P*)
p->f();P::f
c->f();C::f
pc->f();C::f
Point* move(Point* p, int d);require
Point* move(Point* p, int d) { p.x += d; return p; }int Point::x
template< class T >requires
class P { public: P(T& r) : t(r) {} int operator==( P<T>& p) { return t.value() == p.t.value(); } private: T& t; };T::value()
template< class T > class A {\fbox{
public: virtual T value() = 0; }; class Int : public AA }{ \fbox{
public: Int(int n = 0) : _n(n) {} int value() { return _n; } private: int _n; };Int <= A }
Int i1, i2; Pp1(i1), p2(i2); if ( p1 == p2 ) cout << "OK" << endl; OK