fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct Punto
  5. {
  6. double x;
  7. double y;
  8. };
  9.  
  10. class Circulo
  11. {
  12. public:
  13. void centro( const Punto&);
  14. void centro( Punto&) const;
  15.  
  16. private:
  17. Punto centro_;
  18. };
  19.  
  20. void Circulo::centro( const Punto& pto)
  21. {
  22. centro_ = pto;
  23. cout << "void centro( const Punto&)" << endl;
  24. }
  25.  
  26. void Circulo::centro( Punto& pto) const
  27. {
  28. pto = centro_;
  29. cout << "void centro( Punto&) const" << endl;
  30. }
  31.  
  32.  
  33. int main()
  34. {
  35. Circulo circ;
  36. Punto pto;
  37. pto.x = 10;
  38. pto.y = 10;
  39.  
  40. circ.centro( static_cast<const Punto&>(pto));
  41. (circ.*static_cast<void (Circulo::*)(Punto&) const>(&Circulo::centro))( pto);
  42.  
  43. return 0;
  44. }
Success #stdin #stdout 0s 3468KB
stdin
Standard input is empty
stdout
void centro( const Punto&)
void centro( Punto&) const