/*The code below is an example of Dominance.
Functions in the derived classes override the base class methods with
the same name even if the signature is different.
Remove the commented out illegal code and you will get the compiler errors

dominance.cc: In function `int main()':
dominance.cc:33: no matching function for call to `B::B (double)'
dominance.cc:26: candidates are: B::B(const B &)
dominance.cc:23:                 B::B(double, int)
dominance.cc:24:                 B::B()
dominance.cc:38: no matching function for call to `B::Mass (double, int)'
dominance.cc:25: candidates are: B::Mass(double)
dominance.cc:40: no matching function for call to `B::Mass ()'
dominance.cc:25: candidates are: B::Mass(double)
*/

#include <stdio.h>
#include <iostream.h>

class A {
private:
  double myMass;
public:
  A() {}
  A(double x) {myMass = x;}
  double Mass() { return myMass; }
  double Mass(double x, int y) {  myMass = x+y; return myMass; }
  double Mass(double tm) { myMass = tm; return myMass;}
};

class B : public A {
public:
  B(double x, int y) {A::Mass(x,y);}
  B() : A() {}
  double Mass(double tm){return A::Mass(tm);};
};


int main () {
  A x;
  B y;
  B z(4.1,6);
  //  B t(2.3);   //illegal constructor method is not accessable
  x.Mass(2.3);
  x.Mass(2.3,1);
  cout << x.Mass() << endl;
  y.Mass(2.4);
  //  y.Mass(2.4,2);  //illegal method is not accessable
  y.A::Mass(2.4,2);  //okay
  // cout << y.Mass() << endl; //illegal method is not accessable
  cout << y.A::Mass() << endl; //okay
  cout << z.A::Mass() << endl; //okay
  return 0;
}



/* Output
3.3
4.4
10.1
*/
