object overloading

Hi,

i have defined a class inherited from ostream class...

class ABC: public std::ostream
{
public:
ABC ( const std::string &line, enum level )


i create an object of this class and pass some parameters.
I want this object to be overloaded with extraction operator to display some message

ABC a("Hello",enum level);
a<<"bye";


this shows segmentation fault... wt should be done..??
The normal way this is done is to overload a global ostream << operator, then you can put all your stuff in there.

For example:
1
2
3
4
std::ostream& operator<<(std::ostream& os, const ABC &val)
{
    os << val.line << ' ' << val.level;
}

Topic archived. No new replies allowed.