cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
Urgent ::I can't define a function to ac
Urgent ::I can't define a function to accept "" or NULL
Feb 24, 2011 at 8:14am UTC
tonnot
(335)
I have
myclass::operator << (std::string data) {}
myclass::operator << (const char * data) {}
myclass::operator << (bool data) {}
Ok , if I call class<<""; I see that function used is the bool ???????
And If I call class<<NULL; I have a runtime error.
Any idea? Thanks
Last edited on
Feb 24, 2011 at 8:45am UTC
Feb 24, 2011 at 10:27am UTC
Bazzy
(6281)
Why do you keep creating new threads on the same topic? you can keep it in one place.
class
<<
""
should call the const char* overload.
NULL is an integer constant so it will be ambiguous. How should your << act on NULL?
Feb 24, 2011 at 10:45am UTC
tonnot
(335)
Please , delete this post
Last edited on
Feb 24, 2011 at 10:58am UTC
Feb 24, 2011 at 10:53am UTC
Bazzy
(6281)
Why do you call class<<NULL ?
If you have a char pointer you can check if it's NULL before calling <<
Topic archived. No new replies allowed.