diffrence between a char pointer and char pointer inside a class(private)
|
Light Poster
|
|
| 1Oct2010,15:21 | #1 |
|
what is the diffrence between a char pointer and char pointer inside a class(private)
|
|
Ambitious contributor
|
|
| 2Oct2010,02:31 | #2 |
|
The char pointer in the class can only be accessed by class members.
|
|
Light Poster
|
|
| 3Oct2010,13:11 | #3 |
|
i asked about not that diffrence...............
in normal char pointer we can have to allocate contineous memory for storing string(implicitly).......... is it possible in the case of a class member.......................... eg: char *str; scanf("%s",str); will store the strring inside str(without allocating memory explicitly(means not using malloc))............ but is it possibe for a class private member.............. plz mension an eg!!!!!!!!!!!! |
|
Ambitious contributor
|
|
| 3Oct2010,19:00 | #4 |
|
You must explicitly allocate memory for a string in any scope in c/c++. You must first allocate memory for a pointer before using. Your example will produce undefined results. Some times it may seem to work, but it is writing to memory it does not own.
Jim
shabbir
like this
|
|
Light Poster
|
|
| 4Oct2010,13:30 | #5 |
|
but in the case char pointer its always true in normal case...........
what happent in the case of class variable |
