Skip to main content
gamedev.net
🔒 Locked

engine question

Started by dev578 1 reply 400+ views
Original Post
dev578
dev578
I have two questions reguarding my DirectX engine. 1. In my main engine class, I have a lot of variables. The user does not need to see all of them. Whether the variables are private, public, or protected, the user of the class can see all of them in the created instance of the class. What is the best way to hide variables in a class from the user (if any)? 2. When I create an array of, for example, vertex buffers, I do so like this: LPDIRECT3DVERTEXBUFFER9* VertexBuffer; VertexBuffer = new LPDIRECT3DVERTEXBUFFER9[size]; This requires having to know how many vertexbuffers I am going to need. Is there a way that I can do this without having to know the size, so the user can just create as many vertexbuffers as he wants? Any help is appreciated, -Dev578
Caesar
Caesar
1) that is strange. if you have the variables protecetd or private

class CFoo{
protected: //or private:
int my_variable;
};

then you should only be able to use the from the methods of the class (the functions that belong to the class). If a user creates a instance of the class like

CFoo foo;

then you shouldn't be able to do

foo->my_variable; //the compiler should compain the variable is protected

2) yes, linked lists. you might want to take a look at vector (std::vector). look in MSDN. a lot of tutorials around I'm sure

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.