Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
const. pointer or pointer to const. char
#1
Dear sir, i m confused about return type of function in example at page 122. It is written that getter function is returning constant pointer to data memeber ptr. Syntex is "const char *GetString()const."

I m narating this syntex as "GetString function is returning a pointer to constant character" If it is returning a constant pointer then i think syntex should be like "char const *GetSting()const".Please help me what is correct version. Thanks
Reply
#2
This syntax “const char * GetString () const” is correct and it returns a constant character pointer, while “char const * GetString () const” is incorrect, the correct syntax is “char *const GetString () const”, that returns a constant pointer to character.

0300-9520262
Get solution in 24 hour
|cpmputer & internetConfusedmileys81:[SIZE="4"][SIZE="3"]....[/SIZE][/SIZE]
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Explain the difference b/w Null Pointer and Null Nodes? C++ 2012 Vuhelper 0 1,953 01-06-2012, 12:24 AM
Last Post: Vuhelper
  Why we write main rgc,char**argv in C++ 2012 Vuhelper 0 3,022 01-04-2012, 10:36 PM
Last Post: Vuhelper
  call by value, call by reference,call by pointer in data structure 2012 Vuhelper 0 4,334 01-04-2012, 10:28 PM
Last Post: Vuhelper
  What is a Dangling pointer? Briefly explane with example. Vuhelper 0 1,883 11-05-2011, 05:13 PM
Last Post: Vuhelper
  ASCII to char conversion code in C++ 2011 Vuhelper 0 1,724 11-05-2011, 05:01 PM
Last Post: Vuhelper
  Pointer question?? Vuhelper 0 1,422 08-30-2011, 09:55 PM
Last Post: Vuhelper
  How to initializing a const set? Vuhelper 0 1,578 06-21-2011, 07:30 PM
Last Post: Vuhelper
  Memory pool & char array questions in C++ for 2011 Xpert 0 2,255 05-12-2011, 09:16 PM
Last Post: Xpert
  C++ have Virtual Function vs Function Pointer call 2011 Xpert 0 5,918 05-12-2011, 09:03 PM
Last Post: Xpert
  what is cursor and why we use it. what is difference between cursor and pointer. saneha 1 7,712 05-02-2011, 06:47 PM
Last Post: Vuhelper

Forum Jump:


Users browsing this thread: 1 Guest(s)