0

I have a class (String) that I want to be able to implicitly convert to a char. How would I go about doing this? I know to do it the other way around, I just add a constructor that just takes a char as a parameter, but to convert from String to char implicitly? Thanks.

3
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by chaines51
Featured Replies
  • 1

    So you have your home-made String class and want it to implicitly convert to C-string(a zero-terminated character array). You would have to overload the operator char*() Read [url]http://www.informit.com/guides/content.aspx?g=cplusplus&seqNum=24[/url] And always search the web before posting. Read More

0

I have a class (String) that I want to be able to implicitly convert to a char. How would I go about doing this? I know to do it the other way around, I just add a constructor that just takes a char as a parameter, but to convert from String to char implicitly? Thanks.

This any help???:
http://support.microsoft.com/?kbid=311259

0

Actually, I just wanted to convert it to char (as in, a single character).

And, I did search, I just was obviously not using the right terms, IE conversion operator.

Thanks for your help!
Cody

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.