c++ - Member is inaccessible from Template class object in parameter -
i have class has function takes in template list object parameter. using list object i'm supposed to:
//receives list of nvpair objects , sets data value in data member //of object in list according corresponding name in name - value pair
here class , function:
class cartoon : public object { string type; string name; string likes; public: void set(const list<nvpair<string, string>, 10>&& list) { //set list.objarray[0] } };
here list template class:
template<typename t, int max> class list { t objarray[max]; int index; public: list() : index(0) {} size_t size() const { return index; } const t& operator[](int i) const { //try {} shit return <= max && >= 0 ? : -1; } void operator+=(const t& t) { objarray[index++] += t; } void operator+=(t&& t) { objarray[index++] += move(*t); } };
why can't access member objarray? says member inaccessible.
the first template argument of nvpair, class template. is:
template<typename n, typename v> class nvpair { n name; v value; public: nvpair() :name(""), value("") {} nvpair(n n, v v) : name(n), value(v) {} n name() const { return name; } v value() const { return value; } };
i tried setting data members protected instead of private changes nothing. tried setting
void set(const list<nvpair<string, string>, 10> && list)
as pointer type, 1 reference, no reference or pointer nothing changes. member inaccessible. think parameter wrong i'm not sure wrong it.
also object class cartoon derives off of:
class object { public: virtual void set() = 0; virtual const std::string getdsv(char c = value_delminiter) const = 0; };
here code calls set function
auto list = new list <t, objects_per_json_file>(); auto members = new list <nvpair <std::string, std::string>, data_members_per_object>(); //inside switch loop case object_close: obj.set(*members); (*list) += obj; delete members; members = nullptr; break;
i tried setting data members protected instead of private changes nothing
that because access list
in cartoon::set unrelated (in terms of inheritance) list. hence cannot access private or protected members list
.
Comments
Post a Comment