Functions returning pointers
Posted
by
fg nu
on Programmers
See other posts from Programmers
or by fg nu
Published on 2012-10-09T03:45:22Z
Indexed on
2012/10/09
3:49 UTC
Read the original article
Hit count: 279
C++ noob here. I have a very basic question about a construct I found in the C++ book I am reading.
// class declaration
class CStr {
char sData[256];
public:
char* get(void);
};
// implementation of the function
char* CStr::get(void) {
return sData;
}
So the Cstr::get
function is obviously meant to return a character pointer, but the function is passing what looks like the value (return sData
). Does C++ know to return the address of the returned object? My guess would have been that the function definition would be return &sData
.
© Programmers or respective owner