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.
chaines51
0
Junior Poster in Training
Recommended Answers
Jump to PostSo 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 http://www.informit.com/guides/content.aspx?g=cplusplus&seqNum=24
And always search the web …
All 3 Replies
athlon32
56
Junior Poster in Training
siddhant3s
1,429
Practically a Posting Shark
chaines51
commented:
Thanks for the help!
+1
chaines51
0
Junior Poster in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.