Re: Can't compile this code

From: Morten Gulbrandsen (Morten.Gulbrandsen_at_rwth-aachen.de)
Date: 11/25/04


Date: Thu, 25 Nov 2004 11:58:45 +0100


#include <iostream>

using namespace std;

class Cat
{
 private:
  int weight;
  int age;

  void DoMeow()
  {
   cout << "Meow\n";
  }

 public:
  Cat::Cat(int theWeight, int theAge)
  {
   weight = weight;
   age = theAge;
  }

  void Meow(int howManyTimes)
  {
   for (int i = 1; i < howManyTimes; i++)
   {
    DoMeow();
   }
  }

};

int main()
{
 Cat frisky = new Cat(5,3); // cannot convert from 'class Cat *' 'class
Cat'
 frisky.Meow(3);

 return 0;
}

===

Only one error left,

What can I do ?

Yours Sincerely

Morten Gulbrandsen

"Chris ( Val )" <chrisval@bigpond.com.au> wrote in message
news:30lrgiF312gn9U1@uni-berlin.de...
>
> "Morten Gulbrandsen" <Morten.Gulbrandsen@rwth-aachen.de> wrote in message
> news:30lqh7F32t1tcU1@uni-berlin.de...
> | #include <iostream>
> |
> | public class Cat
> ^^^^^^-------------- Here
>
> | {
> | private:
> | int weight;
> | int age;
> |
> | void DoMeow()
> | {
> | cout << "Meow\n": <---- Here
> | }
> |
> | public:
> | Cat::Cat(int theWeight, int theAge)
> | {
> | weight = weight;
> | age = theAge;
> | }
> |
> | void Meow(int howManyTimes)
> | {
> | for (int = i; i < howManyTimes; i++)
> ^^^^^^^^--------------------------- Here
> | {
> | DoMeow();
> | }
> | }
> |
> | }
> |
> | int main()
> | {
> | Cat frisky = new Cat(5,3);
> | frisky.Meow(3);
>
> You have to decide if you want to use a pointer to
> a 'Cat' object or not, and use the appropriate member
> access operator.
>
> Cheers.
> Chris Val
>
>



Relevant Pages