C++ – convert object to char*

by

To easily convert an object to char* you can write an operator like:

class String {
char str[80];

operator char *() { return str; } // convert to char*
}

And the you can use it like this:

char *buf;
String s;
buf =s;

More here:
http://www.ee.cooper.edu/courses/course_pages/past_courses/EID151/CPP.html

Advertisements

3 Responses to “C++ – convert object to char*”

  1. yaaang Says:

    great tips! thanks for running this blog. i’m glad i found it by accident.

    sometimes you seem to be responding to questions – do you frequent any newsgroups/forums/irc channels? or are these from people you know?

    another thing – why wordpress (as opposed to a more structured knowledge base and/or something more open/collaborative)?

    (who are you? must be a busy person to be touching all of these things on a daily basis 🙂

  2. bengaltiger Says:

    Questionable tips! I think this blogger needs to step up and post better tips. I think he is fairly smart, but he needs to bring it to this blog. I see a severe lack of consistency with these tips.

  3. rvernica Says:

    yaaang, we are glad you like our tips.

    Whenever we don’t remember or don’t know something we search the net and then post the solution so that the next time we find it faster. 😀

    We choose a blog setup because is popular and easy to setup.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: