-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |