Array containing different scopes and access types

How would I create one array to contain different scopes and access types such as:

1
2
3
4
5
Account account1 (1111, 1000);
static Account account2  (2222, 2000);
Account account3 (3333, 3000);
static Account account4 (4444, 4000);
Account account5 (5555, 5000);


Would it turn out to be something like this?
 
Account account[5] = { {1111,1000},{2222,2000},{3333,3000},{4444,4000},{5555,5000} };
You can't create a single array that has multiple scopes. The scope of an array depends on where and how it is defined.

Not sure what you're trying to accomplish. Since you seem to have an Account class, you may want to incorporate the concept of a scope as an attribute in your class.

What I mean by that is consider how a symbol table works. Symbol tables might be implemented as a std::stack<std::map>. When the compiler starts, it pushes the map for the global scope. When a function is encountered, it pushes another map on the stack that will contain the local variables.
you could do it with an array of pointers, but I question your design.
Topic archived. No new replies allowed.