Re: cast operator
From: Ron Natalie (ron_at_sensor.com)
Date: 02/17/04
- Next message: Jonathan Turkanis: "Re: cast operator"
- Previous message: Carl Ribbegaardh: "Re: cast operator"
- In reply to: Ali R.: "cast operator"
- Next in thread: Jonathan Turkanis: "Re: cast operator"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 17 Feb 2004 15:56:18 -0500
"Ali R." <nospam@nospam.com> wrote in message news:11vYb.207$xD6.30181429@newssvr11.news.prodigy.com...
> Hi guys,
>
> I have a string class, which is a wrapper for a char *
> with a few operators, like +
Sounds like what you want is a converting constructor, like the std::string
class has.
class String {
public:
String(const char*);
String();
...
};
Then you pretty much give a const char* to anything expecting a String and it will
be converted.
The operator char*() you defined does the opposite (and is probably ill-advised).
It converts you String class to a const char*.
- Next message: Jonathan Turkanis: "Re: cast operator"
- Previous message: Carl Ribbegaardh: "Re: cast operator"
- In reply to: Ali R.: "cast operator"
- Next in thread: Jonathan Turkanis: "Re: cast operator"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|