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:30 ID:1cMh3ula

>>19
Not only do you get massive executables, but you also have to install a 2gb IDE just to compile them.

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