I want to ask two questions here:
- To make a generic print function which is capable of printing an array(or vector) of any datatype (eg. int, char, string etc.)
- To make a print function which takes input an array(or vector) of objects of a class and invokes the print function (already present in class definition) of that class to print contents of each object.
I was asked this question in placement interview for Zillingo. The interviewer first asked me question 1 but after a very bad attempt of mine, he further complicated it and asked question 2.
The solution I gave for question 1 was that I would make a Print class that has several functions by the name print but each takes an array of different datatype as an argument(one function for every existing datatype). I was completely blank after that.:(