我正在尝试使用Visual Studio 2015构建openFrameworks 0.9.0并且正在“无法实例化抽象类”编译失败。但是,我觉得这更像是VS2015语法问题而不是openFrameworks问题。此代码使用Visual Studio 2012和openFrameworks 0.8.4构建。有谁知道实现类的语法应该如何满足VS2015应该看?
VS2015编译的错误是:
ofx*.cpp(46): error C2259: 'ofx*': cannot instantiate abstract class 1> ......\addons\ofx*I\libs\src\ofx*.cpp(46): note: due to following members: 1> ......\addons\ofx*I\libs\src\ofx*.cpp(46): note: 'void ofBaseDraws::draw(float,float,float,float) const': is abstract 1> ...of_v0.9.0_vs_release\libs\openFrameworks\types\ofBaseTypes.h(75): note: see declaration of 'ofBaseDraws::draw'
1> ......\addons\ofx*I\libs\src\ofx*.cpp(46): note: 'void ofBaseDraws::draw(float,float) const': is abstract 1> ...of_v0.9.0_vs_release\libs\openFrameworks\types\ofBaseTypes.h(67): note: see declaration of 'ofBaseDraws::draw'
1> ......\addons\ofx*I\libs\src\ofx*.cpp(46): note: 'float ofBaseDraws::getHeight(void) const': is abstract 1> ...of_v0.9.0_vs_release\libs\openFrameworks\types\ofBaseTypes.h(104): note: see declaration of 'ofBaseDraws::getHeight'
1> ......\addons\ofx*I\libs\src\ofx*.cpp(46): note: 'float ofBaseDraws::getWidth(void) const': is abstract 1> ...of_v0.9.0_vs_release\libs\openFrameworks\types\ofBaseTypes.h(108): note: see declaration of 'ofBaseDraws::getWidth'
继承类的代码: of_v0.9.0_vs_release \库\了openFrameworks \类型\ ofBaseTypes.h
具有抽象对象:ofBaseDraws ...具有以下声明:
/// \brief Draw at a position at the native size.
///
/// Native size is determined by getWidth() and getHeight().
///
/// \param x Draw position on the x axis.
/// \param y Draw position on the y axis.
virtual void draw(float x, float y) const=0;
/// \brief Draw at a position with the specified size.
///
/// \param x Draw position on the x axis.
/// \param y Draw position on the y axis.
/// \param w Draw width.
/// \param h Draw height.
virtual void draw(float x, float y, float w, float h) const=0;
如下:
/// \brief Draw at a position at the native size.
///
/// Native size is determined by getWidth() and getHeight().
///
/// \param x Draw position on the x axis.
/// \param y Draw position on the y axis.
virtual void draw(float x, float y) const=0;
/// \brief Draw at a position with the specified size.
///
/// \param x Draw position on the x axis.
/// \param y Draw position on the y axis.
/// \param w Draw width.
/// \param h Draw height.
virtual void draw(float x, float y, float w, float h) const=0;
...............................................
/// \brief Get the height.
/// \returns the height.
virtual float getHeight() const = 0;
/// \brief Get the width.
/// \returns the width.
virtual float getWidth() const = 0;
使用VS2012构建的openFrameworks 0.8.4代码略有不同:
virtual void draw(float x, float y)=0;
virtual void draw(float x, float y, float w, float h)=0;
...............................................
virtual float getHeight()=0;
virtual float getWidth()=0;
答案 0 :(得分:0)
抱歉,但必须承认自己(尴尬)找到答案:
找到约定:of_v0.9.0_vs_release \ libs \ openFrameworks \ gl \ ofTexture.h:
using ofBaseDraws::draw;
void draw(float x, float y) const;
void draw(float x, float y, float w, float h) const;
float getHeight() const;
float getWidth() const;
//*** and in ofTexture.cpp:
void draw(float x, float y) {
.....
}
void draw(float x, float y, float w, float h) {
....
}
float getHeight() {
return height;
}
float getWidth() {
return width;
}