Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 08-17-2002, 01:53 AM   #1 (permalink)
w00t
Totally Inept
 
w00t's Avatar
 
Join Date: Jul 2002
Location: The Great Northwest
Posts: 195
w00t is on a distinguished road
Exclamation Please....Help...M..E....

Find the bug in this code :

// Demonstrates declaration of constructors and
// destructor for the Cat class

#include <iostream.h>

class Cat // Declaration of the class Cat
{
public:
int GetAge; // accessor function
void SetAge (int Age); // accessor function
void Meow(); // general function
private: // begin private section
int itsAge; // member variable
};

// GetAge, Public accessor function
// Returns value of itsAge member
int Cat::GetAge()
{
return itsAge;
}

// definition of SetAge, public
// accessor function
// returns sets itsAge member
void Cat::SetAge(int Age)
{
// set member variable itsAge to
// value passed in by parameter age
itsAge = Age;
}

// definition of Meow method
// returns: void
// parameters: none
// actions: prints "meow" to screen
void Cat::Meow()
{
cout << "Meow.\n";
}

//create a Cat, set its age, have it
// meow, tell us it's age, then meow again.
int main()
{
Cat Frisky;
Frisky.SetAge (5);
Frisky.Meow();
cout << "Frisky is a cat who is \n ";
cout << Frisky.GetAge() << " Years old.\n";
Frisky.Meow();
return 0;
};
Errors:
Inoname00.cpp(19,2):'Cat::getAge()' is not a member of 'Cat'
Error: Frisky2.cpp(50,26):Call of nonfunction

I've spent a good long time looking for this and if someone could help me, I'd be eternally grateful:rock:

Thanks,
--Cj
__________________
Office Space:
Best Movie.
Ever.

Contrary to popular belief, the true function of a programmer
is to turn coffee into source code.
w00t is offline   Reply With Quote
Old 08-17-2002, 02:02 AM   #2 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,444
sde is on a distinguished road
your problem is in the prototype of the GetAge function. you need to add " () " to the end of it:

Code:
class Cat // Declaration of the class Cat 
{ 
public: 
int GetAge(); // accessor function 
void SetAge (int Age); // accessor function 
void Meow(); // general function 
private: // begin private section 
int itsAge; // member variable 
};
this is the same scripts that introduced me to classes in c++ .. gotta love sams teaching us c++ in 21 days ..
sde is offline   Reply With Quote
Old 08-17-2002, 02:17 AM   #3 (permalink)
w00t
Totally Inept
 
w00t's Avatar
 
Join Date: Jul 2002
Location: The Great Northwest
Posts: 195
w00t is on a distinguished road
WOOHOO!!!!
:rock: :p
Thank you so much, that was eating me alive.
I agree, this is a good book.
__________________
Office Space:
Best Movie.
Ever.

Contrary to popular belief, the true function of a programmer
is to turn coffee into source code.
w00t is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -8. The time now is 03:53 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting