invalid conversion from `int' to `int*' in array
How can i set dimension of array from main program ?
I have Class Loza and I want create object(set capacity and price), and
create field contains of "capacity" integers. But when i want set another
number into field like: aray[i] = 1; compiler will say:
invalid conversion from `int' to `int*' in array
How can i fix this problem ? I just want set element on index in field to
another number(0/1)
class Loza {
public:
Loza(int capacity, int price) {
this->capacity = capacity;
this->price = price;
*aray = new int[capacity];
for (int i = 0; i < capacity; i++) {
aray[i] = 0;
}
}
virtual ~Loza();
void info();
bool set(int i) {
if (aray[i] == 0) {
aray[i] = 1;
return true;
} else {
return false;
}
}
int getCapacity() const {
return capacity;
}
int getPrice() const {
return price;
}
void setCapacity(int pocetMiest) {
this->capacity = pocetMiest;
}
void setPrice(int cenaMiesta) {
this->price = cenaMiesta;
}
private:
int capacity;
int price;
int *aray[];
};
No comments:
Post a Comment