You are calling the constructor of BookType
but you didn't define one. Here is an example
#include <iostream>
#include <string>
#include <vector>
#include <initializer_list>
class BookType {
public:
BookType(std::string s1, std::initializer_list<std::string> l, std::string s2, double d, int i1, int i2, int i3): title(s1), authors(l) {}
private:
std::string title;
std::vector<std::string> authors;
std::string Authors;
};
int main() {
BookType Book2("Sweet",{"lil","lool","lal","ln"},"ssss",29288308.47,8,3,2);
return 0;
}
I added the constructor
BookType(std::string s1, std::initializer_list<std::string> l, std::string s2, double d, int i1, int i2, int i3): title(s1), authors(l) {}
and changed your array of Authors
into a std::vector
of authors
. std::vector
s are easier to handle and can be initialized with an std::initializer_list
. Also a std::initializer_list
is passed to the constructor. ["lil,lool,lal,ln"]
is no array.