std::queue question...

S

SpreadTooThin

I need a queue of two std::strings....

should i define a class
myClass
{
public:
std::string a;
std::string b;
};

std::queue<myClass> q;

?
I'm worried about deep copies and memory leeks....
 
L

Lars Tetzlaff

SpreadTooThin said:
I need a queue of two std::strings....

should i define a class
myClass
{
public:
std::string a;
std::string b;
};

std::queue<myClass> q;
Yes
?
I'm worried about deep copies and memory leeks....

Don't worry, be happy ;)
The strings will be copied and there will be no memory leaks!

Lars
 
J

Juha Nieminen

SpreadTooThin said:
I need a queue of two std::strings....

should i define a class
myClass
{
public:
std::string a;
std::string b;
};

std::queue<myClass> q;

?
I'm worried about deep copies and memory leeks....

There's no 'new' anywhere, and thus no memory leaks. Those classes
have been specifically designed for that purpose.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,202
Latest member
MikoOslo

Latest Threads

Top