Advertisement
Guest User

Untitled

a guest
Jan 18th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. /***********RUST*************//*
  6. struct Point {
  7. x: f64,
  8. y: f64,
  9. }
  10.  
  11. // Implementation block, all `Point` methods go in here
  12. impl Point {
  13. // This is a static method
  14. // Static methods don't need to be called by an instance
  15. // These methods are generally used as constructors
  16. fn origin() -> Point {
  17. Point { x: 0.0, y: 0.0 }
  18. }
  19.  
  20. // Another static method, taking two arguments:
  21. fn new(x: f64, y: f64) -> Point {
  22. Point { x: x, y: y }
  23. }
  24. }
  25. */
  26.  
  27. /**********C++*************/
  28. struct PointScruct {
  29. float x;
  30. float y;
  31. };
  32.  
  33. class Point : PointScruct {
  34.  
  35. static Point origin() {
  36. return Point {x = 0.0, y = 0.0};
  37. }
  38.  
  39. static Point new(float xcoord, float ycoord) {
  40. return Point {x = xcoord, y = ycoord};
  41. }
  42.  
  43. }
  44.  
  45.  
  46. int main() {
  47. Point mypoint;
  48. mypoint.new(3.3, 4.2);
  49.  
  50. cout << "my x is = to: " << mypoint.x << endl;
  51.  
  52. return 0;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement