I have this class:
class user
{
private:
string userid;
string password;
public:
user(){};
user(string a, string b){userid = a; password = b;}
~user(){cout<<"Trace";};
void print ( ostream& out );
};
Every time I try to append to my queue this way aqueue.append(user(userid, password); it will append to my queue but it will call the destructor afterwards. The queue is a basic generic linked list pointing to the next cell. My question is: how to add to a class to a queue with out calling the destructor each time?
Store pointers (e.g. raw pointers,
std::auto_ptr,std::unique_ptr) to the objects you wish to store, rather than the objects themselves.