我的代码:
class MyWindowSettings {
public:
const ofGLFWWindowSettings& get(){
return settings;
}
private:
ofGLFWWindowSettings settings;
};
如何将此类用于需要
ofGLFWWindowSettings
而不是没有getter的MyWindowSettings
的函数?我现在
MyWindowSettings settings;
ofCreateWindow(settings.get());
但我想代替以下内容
MyWindowSettings settings;
ofCreateWindow(settings);
我怎样才能做到这一点?
最佳答案
您可能要做的是使用user-defined convertion运算符
class MyWindowSettings {
public:
operator const ofGLFWWindowSettings&(){
return settings;
}
private:
ofGLFWWindowSettings settings;
};