small and easy problem please help

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Oct 2008
Posts: 3
Reputation: m18 is an unknown quantity at this point 
Solved Threads: 0
m18 m18 is offline Offline
Newbie Poster

small and easy problem please help

 
0
  #1
Oct 30th, 2008
i'm beginner in c++ and i get a problem

the problem is

error C2065: 'radius' : undeclared identifier


and the program
  1. # include <iostream>
  2. using namespace std;
  3.  
  4. class circle
  5. {
  6. public:
  7.  
  8. void setRadius (double r)
  9. {
  10. [COLOR="Red"][B]-[/B][/COLOR] radius = r; [COLOR="Green"] //here the problem and i don't know why it's keep telling me " undeclared identifier "[/COLOR]
  11. }
  12.  
  13. double getRadius()
  14. {
  15. return radius;
  16. }
  17.  
  18.  
  19. double getdiameter()
  20. {
  21. return 2 * radius;
  22. }
  23.  
  24.  
  25. double getarea()
  26. {
  27. return 3.14 * radius * radius;
  28. }
  29.  
  30.  
  31. double getcircumference()
  32. {
  33. return 3.14 * radius * 2;
  34. }
  35.  
  36.  
  37. private:
  38.  
  39. double raduis;
  40.  
  41. };
  42.  
  43.  
  44.  
  45. int main()
  46. {
  47. circle candenter;
  48.  
  49.  
  50. candenter.setRadius (1.5);
  51.  
  52.  
  53. cout << "Please enter the radius" << candenter.getRadius() << endl;
  54.  
  55.  
  56. cout << "Circle information using function members:\n" << endl;
  57.  
  58. cout << "Diameter is " << candenter.getdiameter() << endl;
  59.  
  60. cout << "Circumference is " << candenter.getcircumference() << endl;
  61.  
  62. cout << "Area is \n" << candenter.getarea() << endl;
  63.  
  64.  
  65. cout << "Circle informationusing display function:\n" << endl;
  66.  
  67.  
  68.  
  69. return 0;
  70.  
  71. }
do you know why ?

and thanks
Last edited by Narue; Oct 30th, 2008 at 5:22 pm. Reason: Added code tags
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 273
Reputation: Sci@phy will become famous soon enough Sci@phy will become famous soon enough 
Solved Threads: 42
Sci@phy's Avatar
Sci@phy Sci@phy is offline Offline
Posting Whiz in Training

Re: small and easy problem please help

 
0
  #2
Oct 30th, 2008
- radius = r;
Hmm...
What's wrong with this code:
-a = 300;
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 1,937
Reputation: ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of 
Solved Threads: 278
ddanbe's Avatar
ddanbe ddanbe is offline Offline
Posting Virtuoso

Re: small and easy problem please help

 
0
  #3
Oct 30th, 2008
An error like undeclared variable seems obvious to me.
Unless you are from Mars and don't understand english, this means that a variable is not declared. What I normally do in such cases is declare a variable, in your case radius.
Happy programming!!!
Today is a gift, that's why it is called "The Present".
Make love, no war. Cave ab homine unius libri.
Danny
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 273
Reputation: Sci@phy will become famous soon enough Sci@phy will become famous soon enough 
Solved Threads: 42
Sci@phy's Avatar
Sci@phy Sci@phy is offline Offline
Posting Whiz in Training

Re: small and easy problem please help

 
0
  #4
Oct 30th, 2008
Oh yes, sorry. I thought minus was problem

Check your spelling, and learn how to read errors.
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 3
Reputation: m18 is an unknown quantity at this point 
Solved Threads: 0
m18 m18 is offline Offline
Newbie Poster

Re: small and easy problem please help

 
0
  #5
Oct 30th, 2008
sorry , but i know what it's mean the errors

when i replace radius with m it's work
but i want to know why when i put radius it will not work

my teacher used radius and it work
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 1,937
Reputation: ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of 
Solved Threads: 278
ddanbe's Avatar
ddanbe ddanbe is offline Offline
Posting Virtuoso

Re: small and easy problem please help

 
0
  #6
Oct 30th, 2008
Hey m18 can't you read?
DECLARE the variable radius in your Circle class.
A variable declaration is something like : int a; which declares the variable a to be an integer.
So get yer ya yas out, run like hell and DECLARE that radius variable!!!!!!!
Today is a gift, that's why it is called "The Present".
Make love, no war. Cave ab homine unius libri.
Danny
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 90
Reputation: unbeatable0 is an unknown quantity at this point 
Solved Threads: 12
unbeatable0 unbeatable0 is offline Offline
Junior Poster in Training

Re: small and easy problem please help

 
1
  #7
Oct 30th, 2008
private:

double raduis;

I think you swapped these two letters
Last edited by unbeatable0; Oct 30th, 2008 at 12:37 pm.
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 1,937
Reputation: ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of 
Solved Threads: 278
ddanbe's Avatar
ddanbe ddanbe is offline Offline
Posting Virtuoso

Re: small and easy problem please help

 
0
  #8
Oct 30th, 2008
unbeatable0 yuo are unbaetable!
Today is a gift, that's why it is called "The Present".
Make love, no war. Cave ab homine unius libri.
Danny
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 3
Reputation: m18 is an unknown quantity at this point 
Solved Threads: 0
m18 m18 is offline Offline
Newbie Poster

Re: small and easy problem please help

 
0
  #9
Oct 30th, 2008
sorry , and thanks for your help

ask for any help and i will try to help you
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC