Re: Can't compile this code
From: Karl Heinz Buchegger (kbuchegg_at_gascad.at)
Date: 11/25/04
- Next message: Francis Glassborow: "Re: Can't compile this code"
- Previous message: Chris \( Val \): "Re: Can't compile this code"
- In reply to: Morten Gulbrandsen: "Re: Can't compile this code"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 25 Nov 2004 13:10:52 +0100
Morten Gulbrandsen wrote:
>
> #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 ?
Read a book?
Seriously: You should read a book. I haven't analyzed your
first 2 error messages (since somebody else already did it),
but this error is a trivial one (and the next one that is
waiting in your code is also trivial, *if you know the
basics*). If you are not able to see the problem there is
only one conclusion: You are trying to learn C++ in an
unsystematic way. Believe me: This is boud to fail!
C++ is much to complex to be learned that way. You will end
up with lots of knowledge holes and in the end know a little
bit about everything, but not enough for solid programming.
-- Karl Heinz Buchegger kbuchegg@gascad.at
- Next message: Francis Glassborow: "Re: Can't compile this code"
- Previous message: Chris \( Val \): "Re: Can't compile this code"
- In reply to: Morten Gulbrandsen: "Re: Can't compile this code"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|