c++ - Reference of a function return value -


suppose have this

  class handleinterface {         gluint handle_;     protected:         void sethandle( gluint ) {             handle_ = i;         }      public:         gluint gethandle() const {             return handle_;         }          virtual ~handleinterface() {} }; 

buw need reference of handle_.

// need &handle_ glgenbuffers( 1,&handle_ ); 

do need write getter handle_? or how reference of handle_ getter method?

also glgenbuffers somehow violates sethandle method because should set handle_ though sethandle method , not though reference. ideas how can avoid this?

if want keep handle_ encapsulated, pass local variable glgenbuffers:

gluint handle; glgenbuffers(1, &handle); sethandle(handle); 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -