Mam dwa problemy:
mam jakąś klasę, załóżmy o takiej konstrukcji:
class nazwaKlasy
{
public:
int x;
nazwaKlasy();
bool tablica[x];
int funkcjaKlasy();
};
nazwaKlasy::nazwaKlasy(){
x=4;
}
int nazwaKlasy::funkcjaKlasy()
{
for (int i = 0; i < x; i++) {
srand ( time(NULL) );
tab[i] = rand() % 75 + 50;
return tab;
}
- Jak sprawić by pole klasy jakiegos typu (tutaj int x) mogło być rozmiarem innego pola typu tablicowego (tutaj bool tablica[x])
- Jak sprawic by funkcja klasy (tutaj funkcjaKlasy()) zwracała tablice (tutaj tab)
Kompilator zwraca taki błąd
[BCC32 Error] file2.cpp(18): E2313 Constant expression required
przy linijce
bool tablica[x]
i taki
[BCC32 Error] file2.cpp(39): E2235 Member function must be called or its address taken
przy tej linii
return tab;