c++ - const FILE*& getSequenceFilePointer() const; ECLIPSE -
in .h file .cpp program have following.
file *sequence_file_pointer_; //holds file pointer file itself
told eclipse generate getters , setters , interesting result.
const file*& getsequencefilepointer() const;
after thought knew pointers addresses , constants, see them give me this. understand constant on left return constant file pointer, don't understand constant on right , ampersand between file*
, getsequencefilepointer()
. help?
class configuration { public: const file*& getsequencefilepointer() const; private: file *sequence_file_pointer_; //holds file pointer file }
they taught me use ampersand if needed reference only, not copy, classes/structures. when want return class, int or whatever, copied stack, , can in other function. if want give reference only, example did not create object needed returned within function, pass 4 or 8 bytes, doesn't have copy bunch of memory.
so bit weird. seems bug. pointer atomic (it's unsigned long int
think). doesn't need pass reference, because reference same size points. it's waste of time , memory.
Comments
Post a Comment