Skip to content

Commit

Permalink
Implement 14.
Browse files Browse the repository at this point in the history
  • Loading branch information
alxest committed Aug 9, 2015
1 parent 37b1e7f commit fa4e83c
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
29 changes: 29 additions & 0 deletions 14.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#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;
}
};

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


int main() {
Point* a = new Point(10, 20);
Point3D* b = new Point3D(10, 20, 30);
cout << b->x << " " << b->y << " " << b->z << endl;
}
24 changes: 24 additions & 0 deletions 14.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System;

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

public class Point3D: Point {
public int z;
public Point3D(int x, int y, int z): base(x, y) {
this.z = z;
}
}

class MainRunner {
static void Main() {
Point a = new Point(10, 20);
Point3D b = new Point3D(10, 20, 30);
Console.WriteLine(b.x + " " + b.y + " " + b.z);
}
}

0 comments on commit fa4e83c

Please sign in to comment.