Hi there! I have a problem in dealing with dynamic arrays. I have initialized the objects and now i want to print them.
My class Team looks something like this:Code:// main char* namesList[] = {"Brad Shaw","Aimen Adams","Sal Dimitry","Cristi Anreaz","Poala James"}; int idList[]={232,444,135,52,134}; Team t1( namesList,idList,5,"waqas"); t1.Print_team();
The print function does not work. I have to implement the print function without taking any parameters.. How should i do that ? Thanks!Code:#include <iostream> #include <fstream> #include <string> #include"Team.h" #include "Player.h" using namespace std; Team::Team() { players=0; No_Of_Players=0; Name=0; } Team::Team( char* sNames_List[], int id_List[], int No_Of_Players, char* Name) { Player* players= new Player[No_Of_Players]; for (int i=0; i<No_Of_Players; i++) { players[i].Set_Id(id_List[i]); players[i].Set_Name(sNames_List[i]); players[i].Set_Id(id_List[i]); } } void Team::Print_team() { cout << " the team " << Name << " has " << No_Of_Players << " players namely " << endl; for (int i=0; i<No_Of_Players; i++) { cout << " - " <<players[i].Get_Id() << " " << players[i].Get_Name() << endl; } }