1.在这段代码中我想构造一个点类型的数组并将其每个索引的值初始化为1,2
我可以实现以下代码吗???
2.如果以下代码不起作用,正确的方法是什么???
#include<iostream>
using namespace std;
class point
{
private:
int x,y;
public:
point(int a,int b)
{
cout<<"constructor called here"<<endl;
x=a;
y=b;
}
};
int main()
{
point p[2]{(1,2),(1,2)};
}
Run Code Online (Sandbox Code Playgroud)