How can we declare an oststream object in our own user defined class??
I tried this but it didn't work..
Code:class myclass
{
char str[80];
std::ostrstream(str,80);
};
How can we declare an oststream object in our own user defined class??
I tried this but it didn't work..
Code:class myclass
{
char str[80];
std::ostrstream(str,80);
};
Don't use ostrstream, use std::ostringstream.
Next, why do you want a stringstream as a member of the class?
The ostrstream class is deprecated. Is there any special reason why you want to use it?Quote:
Originally Posted by juice
Yes. You should declare the object as a member:Quote:
Originally Posted by juice
Then initialise it in a constructor. Note that you are not deriving from ostrstream.Code:class myclass
{
char str[80];
std::ostrstream;
};
By using the constructor's initialiser list.Quote:
Originally Posted by juice
No, because a class is a blueprint for objects of the class type.Quote:
Originally Posted by juice