Classes Problem

I have a class that "cooks" food, using a derived class of class 'Food'. Here are the classes:

Class Oven:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
class Oven
{
      private:
              int temperature;
              public:
                     void cook(Food *somefood)
                     {
                        // preheat to temp that somefood needs
                        while(temperature<somefood.getneed())
                        {
                                                          Sleep(40);
                                                          temperature+=1;
                                                          cout<<"Preheat-temperature:"<<temperature;
                                                          }
                                                   }
                                                   void reset()
                                                   {
                                                        temperature=0;
                                                        }
                     };

Class Food:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
class Food
{
      protected:
                int temperature;
                int needed;
                public:
                       int getneed(){return needed;}
                       virtual void bakechem();
      };
      class Pizza:public Food
      {
            public:
            Pizza()
            {
                   temperature = 0;
                   needed = 250;
                   }
                   };

These classes are in different files. I get this error message when I compile, though.

'getneed' has not been declared

It is clearly declared, though! Help? I am passing an instance of class 'pizza' into 'oven.cook', by the way. It is not complete yet.
Last edited on
somefood is a pointer so you have to dereference the pointer to get the Food object.
(*somefood).getneed()
or
somefood->getneed()
^ Oh, I completely forgot about that. :)

Thanks!
One more question... Now it is telling me there is an 'undefined reference to vtable for food'.
Nevermind... I hadn't defined a function in my class...
Topic archived. No new replies allowed.