need help with constructor

getting error conversion from'std::vector<std::basic_string<char> ' to non-scalar type 'std::string {aka std::basic_string<char>}' requested
#trying to pass a vector private data member to a constructor to be used by the\
main
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
using namespace std;


class Sos{
public:
Sos()
{
string host = m_vos;
}
getString(str)
{

}
private:
vector<string> m_vos;
};

int main()
{
Sos string1("smell");


}
Please use code tags for your code - http://www.cplusplus.com/articles/jEywvCM9/

Sos string1("smell");

You don't have a constructor that takes a string do you? All you have in your class is the default constructor.

Edit:

string host = m_vos;

You're trying to assign a vector to a string variable...? Why are you doing that, it makes no sense and obviously brings an error.
Last edited on
very new to c++, just trying to understand some things. I guess im trying to have a constructor that acts as a host object or empty vector and I have a private data member that I believe is a empty vector. I have a member function that takes in a string called void insert (string str) and this function I beileve is suppose to use the constructor Sos in which has the host object and empty vector. I ahve a friend that suggested that I do .clear() c++ function on the empty data member to have an empty vector?
First of all, please don't ignore what I first said and edit your code and use code tags.

You created a vector yes, and it is empty , vector<string> m_vos;

Is this an assignment? Could you post your instructions, would be easier to identify what you're trying to do.
The assignment is to implement the member functions of the class SoS (short for "Set of Strings") defined below. Each SoS object has two data members: m_cofinite, m_vos. The value of m_cofinite is true if the object represents a cofinite set. The vector object m_vos has the strings in the representation. These are either the strings that are in a finite set or the strings that are not in a cofinite set. (For now you can think of a vector as an array. They behave very much like lists in Python or ArrayLists in Java. Section 7.3 of the textbook has an introduction to vectors.) These should be the only data members you need. The requirements for each member function is described below.
working on these functions right now
SoS() ;
The default constructor should set up the host object as an empty set.
void insert(string str) ;
This function should add the string str to the set represented by the host object. You must not have duplicate values stored in m_vos. This is after all a set. Also, you may be inserting str into a cofinite set. In this case, you would want to remove str from m_vos if it is there. Although the vector class does support an erase() method, it is simpler to construct a new vector of strings that omits str and assign the new vector to m_vos.
Topic archived. No new replies allowed.