If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register or Login
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Re: Area and volume of cylinder

Originally Posted by melissax

2kaud i copied with Alt and # pasted it with nice style but when i send i saw that it doesnt change

Before posting, format your code properly with indentations etc. Then Go Advanced, paste in the code, select the code and then click '#'. To format the code you have already posted, on the bottom of your post #12 you should see 'edit post'. Click this, then click Go Advanced, select the code then click '#' then click save. Your code should then be posted correctly formatted.

All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.

Re: Area and volume of cylinder

I tried to do as your opinions still i am getting error. If you help me i will be learn how to do. Thank you.

In a class, by default all members are private - which basically means that they cannot be accessed outside of the class. This is fine for member variables like r and h, but functions such as area and volume need to accessed anywhere. Hence these need to be public. So you need public: before the start of these function definitions. Have a look athttp://www.learncpp.com/cpp-tutorial...ss-specifiers/

In main function, you try to obtain the values of r and h, but r and h aren't declared in function main! You need to declare them in main. Then you need a method function of the class to set the class variables r and h from these values entered. The variables r and h used in function main are not the same variables r and h defined within the class. You should also initialise the class variables to 0 when the class is instantiated by using a default class constructor. Have a look athttp://www.learncpp.com/cpp-tutorial...class-members/

Last edited by 2kaud; May 23rd, 2013 at 01:58 PM.

All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.

Re: Area and volume of cylinder

A lot of your code is nonsense. You need to take a step back and reread whatever book or whatever you've been learning from. We're telling you things that you're not understanding, and you need to have a grasp of the basics that you currently lack. I'm serious that you can't guess your way through C++. You really need to understand what every line you write does.

Re: Area and volume of cylinder

2kaud, i would like to thank you.
With patience you teach me.
Aim of this forum should be guidence.
GCDEF you said "read from book" so you shouldnt give responce.
Why you reply
I understand, but you dont want to help.And you dont know how to talk with a lady.
2kaud, Tomorrow i will try again.
Thank you.

Re: Area and volume of cylinder

Originally Posted by GCDEF

A lot of your code is nonsense. You need to take a step back and reread whatever book or whatever you've been learning from. We're telling you things that you're not understanding, and you need to have a grasp of the basics that you currently lack. I'm serious that you can't guess your way through C++. You really need to understand what every line you write does.

GCDEF is quite correct. You cannot guess c++. You must understand what you are doing. You must have a grasp of the basics before you advance.

As GCDEF said, you really need to take a step back and revise the areas of c++ that have been covered so far so that you understand the basics. Your code indicates that you don't understand - even with the guidance and advice that this forum has provided.

What book(s) etc are you using from which to learn? If you are stuggling with a book, try looking athttp://www.learncpp.com/

which is an easy going tutorial for c++ starting with the basics.

We'll provide what guidance we can, but we are not teachers. This forum cannot teach you c++ - only explain for the code you post problems with guidance to fix. But if you don't understand the basics of c++ you don't understand the guidance we have provided - what is what has been demonstrated in your recent posts. We won't write the code for you - that is cheating. You have to put in the effort to lean properly the language.

All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.

Re: Area and volume of cylinder

Originally Posted by melissax

2kaud, i would like to thank you.
With patience you teach me.
Aim of this forum should be guidence.
GCDEF you said "read from book" so you shouldnt give responce.
Why you reply
I understand, but you dont want to help.And you dont know how to talk with a lady.
2kaud, Tomorrow i will try again.
Thank you.

Whether you like my response or not, it's the truth. I've been trying to help, but you there's only so much any of us can do given your current knowledge. "Learn the basics" is good advice. As to your comment about talking with a lady, that's completely inappropriate in this forum.