【发布时间】:2011-12-20 17:50:38
【问题描述】:
我正在尝试使用自定义类声明一个数组。当我向类添加构造函数时,我的编译器抱怨说“没有匹配的构造函数用于初始化名称 [3]”。
这是我的程序:
#include <iostream>
using namespace std;
class name {
public:
string first;
string last;
name(string a, string b){
first = a;
last = b;
}
};
int main (int argc, const char * argv[])
{
const int howManyNames = 3;
name someName[howManyNames];
return 0;
}
我该怎么做才能让它运行,我做错了什么?
【问题讨论】:
标签: c++ arrays constructor