i'm beginner in c++ and i get a problem

the problem is

error C2065: 'radius' : undeclared identifier


and the program

# include <iostream>
using namespace std;

class circle
{
public:

    void setRadius (double r)
    {
[B]-[/B]      radius = r;  //here the problem and i don't know why it's keep telling me " undeclared identifier "
    }

    double getRadius()
    {
        return radius;
    }


    double getdiameter()
    {
        return 2 * radius;
    }
   
   
    double getarea()
    {
        return 3.14 * radius * radius;
    }
   
   
    double getcircumference()
    {
        return 3.14 * radius * 2;
    }


private:

double raduis;

};



int main()
{
    circle candenter;


    candenter.setRadius (1.5);


    cout << "Please enter the radius" << candenter.getRadius() << endl;


    cout << "Circle information using function members:\n" << endl;

    cout << "Diameter is " << candenter.getdiameter() << endl;

    cout << "Circumference is " << candenter.getcircumference() << endl;

    cout << "Area is \n" << candenter.getarea() << endl;


    cout << "Circle informationusing display function:\n" << endl;

   

return 0;

}

do you know why ?

and thanks

Recommended Answers

All 8 Replies

- radius = r; Hmm...
What's wrong with this code: -a = 300;

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!!!

Oh yes, sorry. I thought minus was problem :)

Check your spelling, and learn how to read errors.

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

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!!!!!!!

private:

double rad[b]ui[/b]s;

I think you swapped these two letters

commented: great observation! +1

unbeatable0 yuo are unbaetable!

sorry , and thanks for your help

ask for any help and i will try to help you

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.