Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

C++ string in class

Name: Anonymous 2007-09-10 20:06 ID:aWmcM4MD


class Myclass {
    public:
        Myclass (char*);
        ~Myclass ();
        char* Myclass ::getName();
    protected:
        char* name;
};

Myclass ::Myclass (char* inname){
    name = new char[strlen(inname)*sizeof(char)];
    strcpy(name, inname);
}

char* Tile::getName(){
    return name;
}


How come name returns a random pointer? I'm declaring everything right, but for some reason it gets corrupted...

Name: Anonymous 2007-09-11 2:28 ID:5GYgZE+H

To be C++ compliant, one should use std::string. But for some crappy reason I can't remember well (something to do with GNU or GPL license or something) some compilers will link statically to the standard library. This gives 400KB+ executable file size for a fucking Hello World. As far as I know this is the case for the GNU c++ compiler. Borland c++ and Visual c++ compiler both provide a dynamic standard library dll (libstdc++.dll or something)

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List