Reputation: 15100
Let's say I have a class with an expensive constructor, and let's say I don't need to create the constructor because it's "simple". Inside the class, I want to put a typedef. All together, it looks like:
class Expensive {
public:
typedef double data_type;
data_type data[100000][100000];
};
Now, in my calling code, if I do:
Expensive::data_type singleValue;
is that going to create a temporary instance of Expensive
and allocate all that space for the data just to get access to the typedef?
Upvotes: 1
Views: 2614
Reputation: 385144
No; you are accessing what is effectively a static member of the class. No instance is created, and thus no huge huge array.
Upvotes: 0
Reputation: 59811
Simply put: No. The operation has no runtime effect whatsoever. Even just declaring a double is not guaranteed to have any effect at runtime as along as you are not using it ;)
Upvotes: 3