我的代码:
class MyWindowSettings {
public:
const ofGLFWWindowSettings& get(){
return settings;
}
private:
ofGLFWWindowSettings settings;
};
如何将此类用于需要ofGLFWWindowSettings
而不是MyWindowSettings
且没有吸气剂的函数?
目前我知道
MyWindowSettings settings;
ofCreateWindow(settings.get());
但是我想代替以下内容
MyWindowSettings settings;
ofCreateWindow(settings);
我该怎么做?
答案 0 :(得分:4)
您可能要做的是使用user-defined convertion运算符
class MyWindowSettings {
public:
operator const ofGLFWWindowSettings&(){
return settings;
}
private:
ofGLFWWindowSettings settings;
};