Click here to Skip to main content
15,902,112 members

Comments by Aswin Waiba (Top 14 by date)

Aswin Waiba 10-Dec-13 3:21am View    
Deleted
<pre lang="xml"><choice> </pre>
Aswin Waiba 4-Dec-13 23:05pm View    
a piece of code like that is present in our project. Don't really understand what it was trying to achieve though :(
Aswin Waiba 28-Nov-13 23:45pm View    
Actually that is just a simplified function. The helper class file contains a lot of templatized classes, each fullfilling a particular function. And As from the above example the MainClass function definitions in helperclass.h uses those templatized classes. However some functions of HelperClass (es) also directly use the static member of MainClass. I want to separate out the two, and at the same time provide access to the static member of MainClass.

Another point to note is HelperClass(es) is derived from HelperParentClass and all the functions are virtual.
Most of the other function of MainClass access HelperClass objects via HelperParentClass pointer.
Aswin Waiba 16-Aug-13 8:31am View    
No, you don't have two definitions of the vector class. You have two *instances* of the vector class. True
But say
when u instantiate vector as
vector<int> obj1;
vector<float> obj2;
means ultimately there will two classes vector<int> and vector<float>

Each time you declare an int, you're not giving the definition of an int, you're simply declaring a variable and telling the compiler that it's an int. True.

But this is true only for integral data types and non-templatised User defined Types(classes)

When we define
template <typename t="">
MyClass
{
T _member;
};

It is a class template. And when you instantiate it as
MyClass<int> or MyClass<float> then ultimately you will be getting two different classes.
Aswin Waiba 16-Aug-13 8:24am View    
when you instantiate a class template. we do have a definition. And when they are in the same file as in ur eg.
vector<int> intVec1;
vector<int> intVec2;
then the vector<int> will be instantiated only once. The second time the compiler encounters vector<int> it uses the already instantiated copy. But when the class template is instantiated on two different Files, we have two different objects containing definition of vector<int> class.