复制构造函数如何在 C++ 中工作
错误 1 错误 C2064:术语不计算为采用 1 个参数的函数 c:\users\thuan\dropbox\homework\css 342\lab2\lab2\lab2\lab2.cpp 26
#include "intset.h"
int main() {
IntSet object1;
IntSet object2(9);
object1(object2); //error here
return 0;
}
//constructor
IntSet::IntSet(int a, int b, int c, int d, int e)
{
numOfArray++;
int tempArray[] = {a, b, c, d, e};
size = determineHighest(tempArray) + 1;
arrayPtr = new bool[size]();
for (int i = 0; i < MAXINITIALSIZE; i++)
{
if (tempArray[i] == -1)
continue;
arrayPtr[tempArray[i]]= true;
}
}
//copy constructor
IntSet::IntSet(const IntSet &intsetObject)
{
numOfArray++;
size = intsetObject.size;
arrayPtr = new bool[size];
for (int i = 0; i < size; i++)
{
if (intsetObject.arrayPtr[i])
arrayPtr[i] = intsetObject.arrayPtr[i];
}
}