using namespace std;
template <typename T>
void add(linked<T> &list1,ifstream& myFile){
string a;
while(!myFile.eof()){
myFile >> a;
T car1;
car1.setName(a);
T& car2 = car1;
list1.addtolist(car2);
}
}
int main(){
linked<car> list1;
ifstream myFile;
myFile.open("car.txt");
add(list1,myFile);
cout << (list1.getElem(1)).getName() << endl;
}
car is a class having a parameter, now I want to pass a list having a class(say bus) object of two parameters and want to read the parameters from a file. How can I change the add function so that it takes one input in case of car and two inputs in case of bus
P.S. linked is linked list class.
Basically , I want to create a function which takes one input if class is car(i.e template T is car) and two inputs if the class is bus.