Skip to content

Commit

Permalink
Add 12
Browse files Browse the repository at this point in the history
  • Loading branch information
alxest committed Aug 9, 2015
1 parent 302019b commit f2123ed
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
25 changes: 25 additions & 0 deletions 12.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include <iostream>
#include <string>

using namespace std;

class Point {
public:
int x;
int y;
Point(int x, int y) {
this->x = x;
this->y = y;
}
};

int main() {
Point* p1 = new Point(0, 0);
Point* p2 = new Point(10, 20);
printf("%s %s\n", "Point", "Point");
printf("%d %d\n", p1->x, p2->x);
p1 = p2;
printf("%d %d\n", p1->x, p2->x);
p1->x = 100;
printf("%d %d\n", p1->x, p2->x);
}
22 changes: 22 additions & 0 deletions 12.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;

public class Point {
public int x, y;
public Point(int x, int y) {
this.x = x;
this.y = y;
}
}

class MainRunner {
static void Main() {
Point p1 = new Point(0, 0);
Point p2 = new Point(10, 20);
Console.WriteLine(p1 + " " + p2);
Console.WriteLine(p1.x + " " + p2.x);
p1 = p2;
Console.WriteLine(p1.x + " " + p2.x);
p1.x = 100;
Console.WriteLine(p1.x + " " + p2.x);
}
}

0 comments on commit f2123ed

Please sign in to comment.