class package
{
public:
class aservice
{
public:
int serviceID;
string othername;
};
int ID;
string name;
vector<aservice> bservice;
void putData(string name1, int serviceID1)
{
bservice.push_back(aservice(serviceID1,name1));
};
};
I want to call the putData from the main file, so when I have the data I can put it inside the vector of "bservice". I don't know how can I define the void putData correctly. I am getting an error of:
error: no matching function for call to 'diagnosis::aservice::aservice(int&, std::string&)'|
The "aservice" is a class that I defined it inside the main class. I tried to push_back the data one at a time, but I think because it is a vector, it didn't work.
What I am trying to do is to read the records from a file and then assign the relevant data to each part of the package. I have a lots of records that belongs to one package (i have different packages) and the basic info would not change (like ID and name). But there are services that I want to grab them from the records and put them into that vector (bservices). The service has different information inside it like name of service, service ID, and date of service. So I cannot store all of the data in a string, I have to do some processes on that vector.
If you want to be able to create aservice objects by doing aservice(serviceID1,name1) you have to define a aservice constructor that takes an int as first argument and std::string as second argument.
In C++11 you can create the aservice object by doing aservice{serviceID1,name1} without having a constructor.
Another way is to first create the aservice object and then set the data members before calling push_back.