假设我有这样的东西
class HandleInterface {
GLuint handle_;
protected:
void SetHandle( GLuint i ) {
handle_ = i;
}
public:
GLuint GetHandle() const {
return handle_;
}
virtual ~HandleInterface() {}
};
现在我需要handle_的引用。
// I would need &handle_
glGenBuffers( 1,&handle_ );
我需要为我的 写另一个吸气剂handle_吗?或者如何handle_从我的 getter 方法中获得参考?
也glGenBuffers以某种方式违反了我的SetHandle方法,因为它应该只handle_通过SetHandle方法而不是通过引用来设置。有什么想法可以避免这种情况吗?