33 lines
422 B
C++
33 lines
422 B
C++
|
#include <iostream>
|
||
|
#include <cstring>
|
||
|
#include <cstdlib>
|
||
|
|
||
|
using namespace std;
|
||
|
|
||
|
class Point
|
||
|
{
|
||
|
private:
|
||
|
int x, y;
|
||
|
|
||
|
public:
|
||
|
Point(int x, int y);
|
||
|
void show()
|
||
|
{
|
||
|
cout << x << "," << y << endl;
|
||
|
}
|
||
|
};
|
||
|
|
||
|
Point::Point(int x, int y)
|
||
|
{
|
||
|
this->x = x;
|
||
|
this->y = y;
|
||
|
}
|
||
|
|
||
|
int main()
|
||
|
{
|
||
|
Point *p1 = new Point[3]{Point(1, 2), Point(2, 3), Point(3, 4)};
|
||
|
p1[2].show();
|
||
|
delete[] p1;
|
||
|
return 0;
|
||
|
}
|