如何给自定义的类的数组赋给初始值
我想给Activity act[100]的前11项赋给初始值,但是报错,请大侠指点一下应该怎么做。
#include <iostream>
#include <algorithm>
using namespace std;
struct Activity
{
int s; //start time
int f; //finish time
};
bool cmp(Activity A,Activity B)
{
return A.f<B.f;
}
int main()
{
Activity act[100]={Activity(1,4),Activity(3,5),Activity(0,6),Activity(5,7),Activity(3,9),Activity(5,9),Activity(6,10),Activity(8,11),Activity(8,12),Activity(2,14),Activity(12,16)};
--------------------报错-----------
ents\visual studio 2005\projects\introductiontoalgorithms\16greedyalgorithms\16greedyalgorithms.cpp(29) : error C2661: 'Activity::Activity' : no overloaded function takes 2 arguments
1>c:\documents and settings\liztac\my documents\visual studio 2005\projects\introductiontoalgorithms\16greedyalgorithms\16greedyalgorithms.cpp(29) : error C2661: 'Activity::Activity' : no overloaded function takes 2 arguments
1>c:\documents and settings\liztac\my documents\visual studio 2005\projects\introductiontoalgorithms\16greedyalgorithms\16greedyalgorithms.cpp(29) : error C2661: 'Activity::Activity' : no overloaded function takes 2 arguments
1>c:\documents and settings\liztac\my documents\visual studio 2005\projects\introductiontoalgorithms\16greedyalgorithms\16greedyalgorithms.cpp(29) : error C2661: 'Activity::Activity' : no overloaded