943,704 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 648
  • C++ RSS
Oct 30th, 2008
0

small and easy problem please help

Expand Post »
i'm beginner in c++ and i get a problem

the problem is

error C2065: 'radius' : undeclared identifier


and the program
C++ Syntax (Toggle Plain Text)
  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
Similar Threads
m18
Reputation Points: 10
Solved Threads: 0
Newbie Poster
m18 is offline Offline
3 posts
since Oct 2008
Oct 30th, 2008
0

Re: small and easy problem please help

- radius = r;
Hmm...
What's wrong with this code:
-a = 300;
Reputation Points: 110
Solved Threads: 43
Posting Whiz in Training
Sci@phy is offline Offline
279 posts
since Sep 2008
Oct 30th, 2008
0

Re: small and easy problem please help

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!!!
Reputation Points: 2023
Solved Threads: 644
Senior Poster
ddanbe is online now Online
3,736 posts
since Oct 2008
Oct 30th, 2008
0

Re: small and easy problem please help

Oh yes, sorry. I thought minus was problem

Check your spelling, and learn how to read errors.
Reputation Points: 110
Solved Threads: 43
Posting Whiz in Training
Sci@phy is offline Offline
279 posts
since Sep 2008
Oct 30th, 2008
0

Re: small and easy problem please help

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
m18
Reputation Points: 10
Solved Threads: 0
Newbie Poster
m18 is offline Offline
3 posts
since Oct 2008
Oct 30th, 2008
0

Re: small and easy problem please help

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!!!!!!!
Reputation Points: 2023
Solved Threads: 644
Senior Poster
ddanbe is online now Online
3,736 posts
since Oct 2008
Oct 30th, 2008
1

Re: small and easy problem please help

private:

double raduis;

I think you swapped these two letters
Last edited by unbeatable0; Oct 30th, 2008 at 12:37 pm.
Reputation Points: 42
Solved Threads: 13
Junior Poster in Training
unbeatable0 is offline Offline
90 posts
since Sep 2008
Oct 30th, 2008
0

Re: small and easy problem please help

unbeatable0 yuo are unbaetable!
Reputation Points: 2023
Solved Threads: 644
Senior Poster
ddanbe is online now Online
3,736 posts
since Oct 2008
Oct 30th, 2008
0

Re: small and easy problem please help

sorry , and thanks for your help

ask for any help and i will try to help you
m18
Reputation Points: 10
Solved Threads: 0
Newbie Poster
m18 is offline Offline
3 posts
since Oct 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: C++ Zeller's Algorithm
Next Thread in C++ Forum Timeline: CreateProcess help!!!





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC