G ++将函数返回struct的原型混淆为struct初始化器

时间:2014-03-11 02:43:56

标签: c++ struct

编译项目时,我收到以下错误:

drawplant.h: In function 'Matrix3f current_matrix()':
drawplant.h:26:1: error: only constructors take member initializers
 Matrix3f mmmult(Matrix3f, Matrix3f);

这是drawplant.h:

#ifndef _DRAWPLANT_H_
#define _DRAWPLANT_H_

/* Functions implemented in drawplant.cpp */

#define PI 3.14159265358


struct Vector3f{
    GLdouble v[4];
} typedef Vector3f;

struct Matrix3f{
    GLdouble m[16];
} typedef Matrix3f;

extern int depth;

void drawPlant();
void push();
void pop();
//void rotate(GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble);
//void translate(GLdouble, GLdouble, GLdouble);
//void scale(GLdouble, GLdouble, GLdouble);
Matrix3f current_matrix(void):
Matrix3f mmmult(Matrix3f, Matrix3f);
Vector3f mvmult(Matrix3f, Vector3f);
#endif  /* _DRAWPLANT_H_ */

1 个答案:

答案 0 :(得分:1)

尝试更改

Matrix3f current_matrix(void):

Matrix3f current_matrix(void);

注意结尾处的分号。