小编Aak*_*ari的帖子

从 int 到非标量类型“point”的 C++ 转换出现错误:

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)

c++ c++14

-1
推荐指数
1
解决办法
178
查看次数

标签 统计

c++ ×1

c++14 ×1