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 12-14-2002, 01:27 PM   #1 (permalink)
w00t
Totally Inept
 
w00t's Avatar
 
Join Date: Jul 2002
Location: The Great Northwest
Posts: 195
w00t is on a distinguished road
Post void(); issues

I'm having a bit of a problem with the public member function void kill(). I would like to have the program run to the meow() function, then execute the kill() function with the data stored in kill().
I'm thinking that i used bool incorrectly. It tells me that "kill" is never used. Anyways, if anyone understands what i just said and has some idea on how to set void kill() straight, i would be very happy
Thanks in advance for reading this.

Code:
// Deomonstrates declaration of a class and
//definition of an object for that class,

#include <iostream.h> //to display on screen

class Cat
{
	public:
      	int its_age;
        int its_weight;
        meow();
        kill();
        };
void meow()
	{
   		cout <<"Meow.\n";
        }

void kill()
{
      int x;
      bool kill(0,1);
      
      cout <<"Would you like to kill Frisky?\n ";
      cin >>x;

         if(kill = 1);
         {
      	cout <<"Thump! \n";
         }
         if(kill = 0)
         {
         cout <<"Okay. *Swerves* \n";
         }
}

void main()
{
   Cat Frisky;
   Frisky.its_age = 5;			//assigns 5 to int_itsage for cat frisky
   Frisky.its_weight = 15;
   
   cout <<"Frisky is a cat who is "		<<Frisky.its_age	
   << " Years old.\n";
   cout <<"Frisky weighs " 	<<Frisky.its_weight	<<" Pounds.\n ";
   meow();
   kill();
   }
__________________
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 12-15-2002, 05:42 PM   #2 (permalink)
DesertWolf
Non-profit Techie
 
DesertWolf's Avatar
 
Join Date: Dec 2002
Location: Mesa AZ
Posts: 76
DesertWolf is on a distinguished road
Send a message via AIM to DesertWolf
Do you have to use bool ?
if not there is a quick fix.
Quote:
void kill()
{
int x;
bool kill(0,1);

cout <<"Would you like to kill Frisky?\n ";
cin >>x;

if(kill = 1);
{
cout <<"Thump! \n";
}
if(kill = 0)
{
cout <<"Okay. *Swerves* \n";
}
}
void kill()
{
int x;

cout <<"Would you like to kill Frisky? 1 for Yes , 0 for No\n ";
cin >>x;

if(x == 1);
{
cout <<"Thump! \n";
}
if(x == 0)
{
cout <<"Okay. *Swerves* \n";
}
}
If you have to use bool let me know and I will see what I can do.
DesertWolf is offline   Reply With Quote
Old 12-15-2002, 05:56 PM   #3 (permalink)
anon
Guest
 
Posts: n/a
Er... I believe this was posted in July... ;]
  Reply With Quote
Old 12-15-2002, 06:08 PM   #4 (permalink)
DesertWolf
Non-profit Techie
 
DesertWolf's Avatar
 
Join Date: Dec 2002
Location: Mesa AZ
Posts: 76
DesertWolf is on a distinguished road
Send a message via AIM to DesertWolf
I didn't look at the date...I was just browsing at it showed as a recent post for some reason....Must be this Microsoft Browser being used on a Mac....
DesertWolf is offline   Reply With Quote
Old 12-15-2002, 07:00 PM   #5 (permalink)
revolution
Legend in my own mind
 
revolution's Avatar
 
Join Date: May 2002
Location: florida
Posts: 618
revolution is on a distinguished road
Send a message via AIM to revolution
it shows yesterday at 5:27pm as the post date
__________________
Is it me or does the word abbreviation seem a little long?


registered user #193524 with the Linux Counter,
http://counter.li.org
revolution is offline   Reply With Quote
Old 12-15-2002, 07:45 PM   #6 (permalink)
anon
Guest
 
Posts: n/a
DAMN IT! I was looking at the date that he registrated... :o... Never mind than... woops... :]
  Reply With Quote
Old 12-15-2002, 07:51 PM   #7 (permalink)
w00t
Totally Inept
 
w00t's Avatar
 
Join Date: Jul 2002
Location: The Great Northwest
Posts: 195
w00t is on a distinguished road
Aahh... Thanks, DesertWolf. I don't have to use bool, so that will be a good fix to the problem.

edit: Fixed it and it works fine :rock:
__________________
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 12-16-2002, 05:14 AM   #8 (permalink)
DesertWolf
Non-profit Techie
 
DesertWolf's Avatar
 
Join Date: Dec 2002
Location: Mesa AZ
Posts: 76
DesertWolf is on a distinguished road
Send a message via AIM to DesertWolf
Your problem was you had bool in your method, but you were taking an int in as your answer to your "Do you want to kill" question, and there was no interaction between the bool and the int. Also you had "=" which is an assignment operator, when you should have had "==" to check equality.
That wasn't too bad a question, you should see some of the problems my students (I tutor CIS courses at my College) come up with.

Oh yea, Vlad..I think you should owe me a beer for that one..
DesertWolf 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


Similar Threads
Thread Thread Starter Forum Replies Last Post
2D graphic repaint logic ralphtan Java 1 08-13-2004 03:49 AM
more help needed kashif Standard C, C++ 0 04-21-2003 10:30 AM
dynamic allocation..urgent help needed!!! kashif Standard C, C++ 4 04-21-2003 08:50 AM
I'm having some problems with inheritance... <-- newb mik0rs Standard C, C++ 5 04-08-2003 10:54 PM


All times are GMT -8. The time now is 03:16 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