hello , i used an array using aggregration in OOP in order to insert multiple datatypes in the array
and i wanted to convert it into dynamic array , so as to edit the entries
and here is the code of the 2 classes and the main function
#include<iostream>
#include<string>
using namespace std;
class player
{
private:
string name;
int age ;
int no;
public:
player()
{
}
player(string name1 , int age1 , int no1)
{
name=name1;
age=age1;
no=no1;
}
void print()
{
cout<<name<<endl;
cout<<age<<endl;
cout<<no<<endl;
}
};
#include<iostream>
#include<string>
#include"Player.h"
using namespace std;
class team
{
private :
player players[11];
string name;
int counter;
public:
team(string name1)
{
name=name1;
counter=0;
}
void addplayer(player p)
{
players[counter]= p;
counter ++;
}
void print()
{
int i;
for ( i=0;i<11;i++)
{
players[i].print();
}
}
};
#include<iostream>
#include<string>
#include"team.h"
using namespace std;
int main()
{
team A("abc");
int x;
string n;
int a;
int kn;
while(1==1)
{
cout<<"1.Add Player"<<endl;
cout<<"2.exit"<<endl;
cin>>x;
switch(x)
{
case 1:
cout<<"enter player info"<<endl;
cin>>n>>a>>kn;
A.addplayer(player(n,a,kn));
A.print();
break;
case 2:
return 0;
break;
}
}
return 0;
}
the program is supposed to enter players & edit and delete them , with the static array i can just insert them , but i have to use dynamic arrays so i can edit and delete the data
plz help me , how can i convert it from a static array into a dynamic one