I really can't find anything related to my problem on the internet (probably because i can't explain the problem), so if someone can help me I would seriously appriciate it. I'm just beginning to learn C++, so forgive my crude title - The problem is as follows:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
class Plaza {
public:
int duljina;
double X;
double Y;
Predmet *niz[50];
};
class Predmet {
public:
string opis;
int kolicina;
};
int main() {
int i, N, M, x;
cout << "Unesite broj plaža (N):";
cin >> N;
Plaza* P = new Plaza[N];
for (i = 1; i <= N; i++) {
cout << "Unesite velicinu i lokaciju za" << i << ". plazu:";
cout << endl;
cin >> P[i].duljina;
cin >> P[i].X;
cin >> P[i].Y;
};
cout << "Unesite broj predmeta (M): ";
cin >> M;
for (i = 1; i <= M; i++) {
cout << "Unesite redni broj plaze kojoj pripada" << i << ". predmet: ";
cin >> x;
cout << "Unesite kolicinu i opis predmeta: ";
cin >> P[0].niz[0].opis;
.......
}
}
Plaza is the main class and the Predmet is the child class. I have an array of classes Plaza which in itself has an array of classes Predmet.
My question is: how the hell do I get to the variables in the Predmet class which is in a list which is in a class that is in an array?
Plaza* temp = new Plaza[X];
temp[0].niz[0].opis; // "Expression must have class type error"
I kid you not, I'm stuck on this problem for 5 hours now... Please help
Thx