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?

Recommended Answers

All 3 Replies

is the error on line 7 or 8?

If its on 7 where is ConstantBuffer defined?

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.

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.