So I am very new at C++ and I have been given a task of creating a class along with its header file so test.h and test.cpp. Now I need to create a constructor that takes a vector of doubles as an argument and uses it to initialise the object. However, I am not able to figure out how to accurately do this. This is what I have added on my header and cpp class and I'm getting an error
Header file:
#include <string>
#include <vector>
using namespace std;
class Dog
{
int age;
string name;
vector<long double> myVector;
public:
Dog();
Dog(string name, int age, vector<long double> myVector);
};
#endif // DOG_H
cpp file:
using namespace std;
Dog::Dog()
{
cout << "Dog object created"<< endl;
}
Dog::Dog(string name, int age, vector<long double> myVector)
: name(name), age(age), myVector(myVector.push_back(myVector))
{
cout << name<<" "<< age <<" "<<myVector<< endl;
}
now in my main class if i add this:
Dog d("Kelly",3,988);
and run the program I get the no match for operator error.