Y
yinglcs
I have a class which has an attribute 'path' of type 'string'.
class MyClass {
public:
MyClass(const string& parentpath, int count) ;
void dump(ostream& os) const;
private:
string path;
int type;
}
MyClass::MyClass(const string& parentpath, int count) {
type = // a function to find out type;
ostringstream apath;
apath << parentpath;
apath << "/";
apath << count;
path = apath.str();
}
void MyClass::dump(ostream& os) const {
os << " type:" << type;
os << " path:" << path;
os << endl;
}
In some case, not always , I this print out junk at the end of 'path',
type:3 path:/-/3/3/3/0/0^@^@^@^@1^@^@^@^@#b^Hh^LU^^AA
Can you please tell me what did I do wrong?
Thank you.
class MyClass {
public:
MyClass(const string& parentpath, int count) ;
void dump(ostream& os) const;
private:
string path;
int type;
}
MyClass::MyClass(const string& parentpath, int count) {
type = // a function to find out type;
ostringstream apath;
apath << parentpath;
apath << "/";
apath << count;
path = apath.str();
}
void MyClass::dump(ostream& os) const {
os << " type:" << type;
os << " path:" << path;
os << endl;
}
In some case, not always , I this print out junk at the end of 'path',
type:3 path:/-/3/3/3/0/0^@^@^@^@1^@^@^@^@#b^Hh^LU^^AA
Can you please tell me what did I do wrong?
Thank you.