We have learnt that Templates in C are a very powerful feature. They constitute the concept of Generic Programming or Type Independent Programming. Last time, we saw templates that have one parameter or one generic type. They have the limitation that only one type of data type can be processed at a time. To solve that problem, we use templates with more than one type of parameters. Such multiple type templates allow more than one type of data types to be process at once.
For Novice and Beginners, C seems a very difficult and challenging language to learn. I won’t say that this is incorrect in entirety though constant practice and hard work makes it easier to code in C .
Here I shall briefly describe some of the Online Resources which I have used personally and found extremely useful. These include resources for learning, debugging to problem solving.
A constructor in a class is a special function called at instantiation of an object, or declaration of an object. What it does is simple: it does everything that you require to be done automatically every time an object of your class is created. This helps us to avoid system crashes and makes sure that the object we create does not always create variable or data that is unacceptable for our program. This will become clearer to you as you read on.
C++ is a very powerful and fast language. One potential danger because of this is the ability of language to call methods and convert data into other types automatically without asking the programmer. So the programmer has an added responsibility of keeping an eye on the compiler and watch out for all such errors. One such common problem is the implicit conversion through a constructor. To avoid that, we use an explicit constructor in C++. Let us see a sample code for that and then I shall explain to you what actually happens.