如何在C++中拷貝構造函數工作複製構造函數是如何工作的?
錯誤1個錯誤C2064:術語不計算爲服用1個參數C中的函數:\用戶\順\保管箱\作業\ CSS 342 \實驗2 \實驗2 \實驗2 \實驗2 .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];
}
}
其中是類? – 2012-04-07 10:24:17