Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- /***********RUST*************//*
- struct Point {
- x: f64,
- y: f64,
- }
- // Implementation block, all `Point` methods go in here
- impl Point {
- // This is a static method
- // Static methods don't need to be called by an instance
- // These methods are generally used as constructors
- fn origin() -> Point {
- Point { x: 0.0, y: 0.0 }
- }
- // Another static method, taking two arguments:
- fn new(x: f64, y: f64) -> Point {
- Point { x: x, y: y }
- }
- }
- */
- /**********C++*************/
- struct PointScruct {
- float x;
- float y;
- };
- class Point : PointScruct {
- static Point origin() {
- return Point {x = 0.0, y = 0.0};
- }
- static Point new(float xcoord, float ycoord) {
- return Point {x = xcoord, y = ycoord};
- }
- }
- int main() {
- Point mypoint;
- mypoint.new(3.3, 4.2);
- cout << "my x is = to: " << mypoint.x << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement