-
March 27th, 2010, 01:17 PM
#1
C2236: unexpected 'class'
i have one header file Matrix4x4.h . it includes another header files. when i compile the code. it gives error "C2236: unexpected 'class' 'Matrix3x3'. Did you forget a ';'? " where i made mistake. how can i fix the problem. thanks in advance
Code:
#ifndef matrix4x4
#define matrix4x4
#include "Vector2D.h"
#include "Vector3D.h"
#include "Vector4D.h"
#include "Matrix3x3.h"
class Matrix3x3; // compiler shows here error C2236
class Matrix4x4
{
public:
..................................
..................................
Matrix4x4& operator=(const Matrix4x4& matrix1);
Matrix4x4& operator=(const Matrix3x3& matrix1);
friend Matrix4x4 operator-(const Matrix4x4& matrix1, const Matrix4x4& matrix2);
friend Matrix4x4 operator+(const Matrix4x4& matrix1, const Matrix4x4& matrix2);
friend Matrix4x4 operator*(const Matrix4x4& matrix1, const Matrix4x4& matrix2);
friend Matrix4x4 operator*(const Matrix4x4& matrix1, const Matrix3x3& matrix2);
friend Vector4D operator*(const Matrix4x4& matrix1, const Vector4D& v);
friend Vector3D operator*(const Matrix4x4& matrix1, const Vector3D& v);
friend Vector2D operator*(const Matrix4x4& matrix1, const Vector2D& v);
friend Vector4D operator*(const Vector4D& v, const Matrix4x4& matrix1);
friend Vector3D operator*(const Vector3D& v, const Matrix4x4& matrix1);
friend Vector2D operator*(const Vector2D& v, const Matrix4x4& matrix1);
friend Matrix4x4 operator*(float t, const Matrix4x4& matrix1);
friend Matrix4x4 operator*(const Matrix4x4& matrix1, float t);
public:
float m[16];
};
#endif
-
March 27th, 2010, 01:30 PM
#2
Re: C2236: unexpected 'class'
i fixed the problem. i forget putting semicolon end of the Matrix3x3 class. now code is working thanks have a nice evening
-
March 27th, 2010, 01:52 PM
#3
Re: C2236: unexpected 'class'
if you were including the header, what is the point in forward declaring it as well??
-
March 27th, 2010, 02:43 PM
#4
Re: C2236: unexpected 'class'
i read article says if there is 2 class like
//A.h
class A
and
//B.h
class B
if class B uses reference or pointers to A. use forward declaration. you dont need to include A.h. if B uses object of class A. you then need to include <A.h>
compiler shows error coming from class Matrix3x3 so i used forward declaration and includes to find out errors. the error arrises from semicolon end of the Matrix3x3 class.now i use forward declaration instead of includes.
thank you Amleto
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|