Vector Class Creation


when i have added template functionality, there is some runtime error, plz check the code and revert the changes

Hello @akb.tech17,

The runtime error is not due to template.
Look at the following code:
vector() //user defined (Default) constructor
{
arr = NULL;
csize = 0;
msize = 0;
}
//arr is pointing to null.

So, when the statement vector v2; will execute,
it will call the default constructor.

After executing the next statement i.e. v2.push_back(‘a’);
push_back() function will be called.

But you are not handling the case when arr=NULL.
This is the reason of runtime error.

Hope, this would help.
Give a like if you are satisfied.