Advertisement Jump to content


This topic is now archived and is closed to further replies.



This topic is 5822 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi there, I got two questions regarding lookup tables: 1. How do you fill one in a neat way if the contents don''t match any pattern ? ( Example: IndexTable[2][2][16] ) If it''s a part of a class and let''s say all the instances wanna use this table... 2. What is a good approach to initialize it ? So far my ideas were the following: 1. The array is ''static'' in the class 2. A static function like InitTable()that is called before the first instance. 3. Like 2. but the function is called in the constructor with a static flag to prevent further initialization. Somehow I don''t like those. Is there a better way ? Any comment appreciated. Lorenz

Share this post

Link to post
Share on other sites
int a[3][2] = {{1,2},{3,4},{5,6}};

If all instances wanna share it, you can do it with statics..

struct B {
static const A a[2];

const A B::a[2] = { A(1), A(2) };

Or maybe have InitTable() that eg. loads it from a file. Whatever you prefer.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!