Hi there! I have a problem in dealing with dynamic arrays. I have initialized the objects and now i want to print them.
My main function looks like this:
char* namesList[] = {"Brad Shaw","Aimen Adams","Sal Dimitry","Cristi Anreaz","Poala James"};
int idList[]={232,444,135,52,134};
Team t;
Team t1( namesList,idList,5,"waqas");
//t1.Print_team();
My class Team looks like this:
#include <iostream>
#include <fstream>
#include <string>
#include"Team.h"
#include "Player.h"
using namespace std;
class Team
{
private:
Player* players; // class Player has two members i.e. char* name, int id
int No_Of_Players;
char* Name;
}
public:
Team::Team()
{
Player* 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]);
cout << players[i].Get_Id() << " " << players[i].Get_Name() << endl;
}
}
/*
void Team::Print_team()
{
cout << " the team " << Name << " has " << No_Of_Players << " namely " << endl;
for (int i=0; i<No_Of_Players; i++)
{
cout << " - " <<players[i].Get_Id() << " " << players[i].Get_Name() << endl;
}
}
*/
Now the problem is that how do i print the values using the print function?