0

Using this code:

class box
    {
    public:
        int x;
        int y;
        XMMATRIX  world;
        ConstantBuffer cb;
        cb.mWorld = XMMatrixTranspose( world );
        box(int a, int b){x=a;y=b;}

    };

Gives error on "cb"(This declaration has no storage type or class or type specifier.

What should i do about this?
Is it not possible to make a object in class definition?

3
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by StuXYZ
0

is the error on line 7 or 8?

If its on 7 where is ConstantBuffer defined?

Edited by gerard4143: n/a

0

sorry, line 8.
ConstantBuffer is a struct defined before wWinMain.
Im altought defining the class inside my render function wich is looped.....Il take a check if thats the probleem...Nope

Now defined before winmain after ConstantBuffer and im getting the same error.

Edited by frogster: n/a

0

The error is because this is a definition of a class. You have then put initialization code in it which is not going to work.

You could do something like this:

class box
    {
    public:
        int x;
        int y;
        XMMATRIX  world;
        ConstantBuffer cb;
 
        // constructor
        box(int a, int b)  : x(a),y(b) 
         { cb.mWorld=XMMatrixTranspose(world); }

    };

Here I have added the cb.mWorld to your constructor. You might have to think about if this makes sense in your context, and what to do about the assigment operator, and the copy constructor.

Edited by StuXYZ: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.