Runtime error. Terminate called after throwing an instance of std::length_error

I get a Runtime error which i can't understand. Please help!

class A
{ private:
string x, string y;
double z;
public:
A(string,string,double) // parameterized constructor
}

A CreateA(A& newA) // function returning an A object
{
newA = A(a,b,c) // a,b,c are entered by user from cin as string,string,
// double respectively.
}

int main()
{
A a;
vector <A> list;
list.push_back(CreateA(a));
}






you did not return anything from CreateA which is misnamed badly. (It does not create anything).

You need to return newA in (and, it should be A& CreateA(... ) I believe)
see if that works?
Thank you Jonnin. I made the function CreateA() as a void function and it worked. There was no need for me to return any thing because i passed by reference. Thanks again!
Topic archived. No new replies allowed.