vendredi 12 février 2021

confusion about templates with user created classes

Assuming I have something like this

class Food
{
      public:
       Food();
       int getprice();
      protected:
        int price;
}
class Hamburger
{
      public:
      Hamburger(int price);
      private:

       List <Food> li;
       friend class Food;
}

How would I access the member variables of Food like its getprice or its member variables through using li? I've tried li.getprice() in the constructor for Hamburger but it resulted in an error message of List has no member named getprice.

Aucun commentaire:

Enregistrer un commentaire