B
bintom
Hey, can anybody tell me what I'm doing wrong in the following
program?
The output generated is some junk characters followed by 5 (the size
of "Texas").
Thanks,
Bintom
#include <iostream.h>
class state
{ char *name;
int size;
public : state(char* s)
{ size = strlen(s);
name = new char[size + 1];
}
void display()
{ cout << name << " " << size << "\n"; }
};
int main()
{ state S1("Texas");
S1.display();}
}
program?
The output generated is some junk characters followed by 5 (the size
of "Texas").
Thanks,
Bintom
#include <iostream.h>
class state
{ char *name;
int size;
public : state(char* s)
{ size = strlen(s);
name = new char[size + 1];
}
void display()
{ cout << name << " " << size << "\n"; }
};
int main()
{ state S1("Texas");
S1.display();}
}