qfedu-cpp-level/day3/homework/h3.cpp

33 lines
422 B
C++
Raw Normal View History

2023-07-26 21:10:02 +08:00
#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;
}