Mam program który powienien wczytywać 5 ciągów znaków, potem zwiększać tablicę o 5 i wczytać 5 nastepnych ciągów, ale tego nie robi. Co jest źle?
PS Wiem że zmienne w klasach nie powinny być tak deklarowane.
#include <iostream>
#include <string>
using namespace std;
class Array
{
int operation; //zmienna do forów
int value=5; //wielkosc tablicy
int counter=0; //numer komorki
string *namesArray=new string[value];
public:
Array()
{
}
void print()
{
cout<<"Dane:"<<endl;
for(operation=0;operation<value;operation++)
{
cout<<namesArray[operation]<<endl;
}
}
void names(string data)
{
if(counter==value)
{
string *namesBigger;
namesBigger=new string[value*2];
for(operation=0;operation<value;operation++)
{
namesBigger[operation]=namesArray[operation];
}
namesArray=namesBigger;
}
namesArray[counter]=data;
counter++;
}
};
int main()
{
Array add;
string name;
for(int operation=0;operation<10;operation++)
{
cout<<"Podaj dane"<<endl;
cin>>name;
add.names(name);
add.print();
}
}