示例#1
0
int main()
{
  int x , y;
  char temp; // garbage value of ,
  cout << "Enter cordinate x y in format x,y";
  cin >> x >> temp >> y;
  Coordinate a(x,y);
  cout << "Enter cordinate x y in format x,y";
  cin >> x >> temp >> y;
  Coordinate b(x,y);
  Vector v; 
  Coordinate c = v.add(a,b);
  cout << "The sum is ";
  c.display();
  cout << endl;
  Coordinate d = v.sub(a,b);
  cout << "The difference is";
  d.display();
  cout << endl;
  Coordinate p = v.mul(a,b);
  cout << "The product is";
  p.display();
  cout << endl;
  Coordinate q = v.div(a,b);
  cout << "The quotient is";
  q.display();
  cout << endl;
  return SUCCESS;
}
示例#2
0
int main()
{
    Coordinate pointA;
    pointA.display();
    pointA.setX(3);
    pointA.setY(5);
    pointA.display();
    int num = pointA.getY();
    cout << "num = " << *num << endl;
    
    Coordinate *ptrA = &pointA;
    int num2 = ptrA->getX(); // ptrA->getX() is an rvalue
    cout << "num2 = " << num2 << endl;

    return 0;
}