I am implementing a sort of array in my class. Its somewhat like this.
Now I understand that for each different type of instantaniation of an object using a template, the compiler does a sort of 'copying and pasting the code' making necessary changes and avoiding pitfalls. So if I make, say like 5 small arrays at different places,Code://blah...blah... template<int Size = 10> class Array{ private: double a[Size]; //blah...blah.. };
Will my program code become very large when the compiler 'copies and pastes' 5 different types of array classes.Code:int main(){ //blah...blah... Array<4> one; Array<3> two; Array<10> three; Array<15> four; Array<8> five; //blah...blah... }
Is dynamic allocaton of arrays better in this case?
P.S I am using templates to avoid 'cleaning up after myself' after doing dynamic allocations and also to learn templates in detail.



LinkBack URL
About LinkBacks


