I read the FAQ and all the articles before I posted, I dont think im getting my point across, or either you think I just started with C++. Lets take this for example.
Code:
class A {
public:
A() {
i = new int[30];
}
~A() {
delete i;
}
private
int* i;
};
class B {
public:
private:
int i[30];
};
Both will work and offer the same function, if things work the way I think, then B has a larger footprint in active memory than A. And in the case of very large classes that may take up KBs of space, how does this play out? What are the pros and cons of the two methods?
Dynamically allocated members are not initialized until you, the programmer, tell the computer to do so. So in the event that maybe you don't want to allocate some memory unless you need to you should make it dynamic.
I think 'initialized' may not have been the proper word, or I may just be confused. So, your saying that if the class needs the data member to always exist during the course of the program execution, then the data member in question should not be dynamically allocated. Even if the data member is very large? Having very large data members declared directly into the class will bloat the memory size of the class, correct?