0
class Skladiste
{
    double max;
    int n;
    Element** niz;

    public:
        Skladiste(double max, int n);
        ~Skladiste();
        void addElement(Element& e);
        double kolicina();
        void printCodes();
        friend ostream& operator<<(ostream& izlaz, Skladiste& s);
        Element* operator[](int n);
};

void Skladiste::addElement(Element& e)
{
    int m;
    n=m;
    if(this->kolicina()+e.vratiKolicinu()<max)
    {
        niz[m]=e;
        m++;
    }
    this->n=m;
}

This method is where I have problem. I need to assign to niz an element e in the last place n. The Element is an abstract class so I cannot make objects of that type. I'm beginner so I would appreciate any help :)

Vasilis G.
  • 7,556
  • 4
  • 19
  • 29
  • These statements int m; n=m; do not make sense. – Vlad from Moscow Nov 23 '17 at 23:09
  • Even if [arrays can decay](https://stackoverflow.com/questions/1461432/what-is-array-decaying) into pointers, it is not the same things !! A pointer of pointer can only hold a single value while the other can have several. If the number of elements is known in advance, you can use `Element*[]`. If you don't know the number of elements in advance, use `std::vector` – Xatyrian Nov 23 '17 at 23:11
  • @Jovana Dimitrijevic Use English words for identifiers. – Vlad from Moscow Nov 23 '17 at 23:11

0 Answers0