C2236: unexpected 'class'
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: C2236: unexpected 'class'

  1. #1
    Join Date
    Jan 2010
    Posts
    26

    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

  2. #2
    Join Date
    Jan 2010
    Posts
    26

    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

  3. #3
    Join Date
    Apr 2008
    Posts
    726

    Re: C2236: unexpected 'class'

    if you were including the header, what is the point in forward declaring it as well??

  4. #4
    Join Date
    Jan 2010
    Posts
    26

    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
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center