I'm trying to initialize an array of structs, but the structs demand arguments upon initialization, like this:
#include <iostream>
using namespace std;
struct MyStruct{
string par1;
double par2;
MyStruct(string var1, double var2){
par1=var1;
par2=var2;
}
};
int main(){
MyStruct test("apples", 17.5);
MyStruct MyArray[3];
return 0;
}
the structure 'test' initializes without problem, but when MyArray tries to initialize, it gives me
'no matching function for call to MyStruct::MyStruct()'
and also
'candidate expects 2 arguments, 0 provided'
I assume this is because I have to initialize it using some arguments for par1 and par2, but I don't know how to, or if it's even possible. I would appreciate any help, thank you.
push_back.