Creating a generalised Vector header file

While writing the Vector header file code, why did Bhaiya not return ‘T’ instead of ‘int’ from capacity() and size()?

type T is used only for array elements so whenever we are returning array element function will return T. while cs and ms are integral values not array elements hence capacity() and size() will return int.

Can we declare ‘T’ as the datatype of cs and ms as?

we have used T since vector elements can be of any types ( for ex int, char etc) but cs and ms should always be integer so if you define T as datatype of cs and ms it will only work for vector of type integer.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.