[ create a new paste ] login | about

Link: http://codepad.org/1M6Efs4C    [ raw code | output | fork ]

salvador@conclase.net - C++, pasted on Nov 22:
// ParĂ¡metros con valores por defecto
// (C) 2009 Con Clase
// Salvador Pozo

#include <iostream>
using namespace std;
 
class punto {
  public:
   punto(float xi, float yi, float zi) : 
      x(xi), y(yi), z(zi) {}
   
   void Asignar(float xi, float yi = 0, float zi = 0) {
      x = xi;
      y = yi;
      z = zi;
   }

   void Ver() {
      cout << "(" << x << "," << y << "," 
           << z << ")" << endl;
   }
   
  private:
   float x, y, z;
}; 

int main() {
   punto P(0,0,0);
   
   P.Ver();
   P.Asignar(12);
   P.Ver();
   P.Asignar(16,35);
   P.Ver();
   P.Asignar(34,43,12);
   P.Ver();

   return 0;
}


Output:
1
2
3
4
(0,0,0)
(12,0,0)
(16,35,0)
(34,43,12)


Create a new paste based on this one


Comments: