Search:
Type: Posts; User: 2kaud
Search:
Search took 0.06 seconds.
-
Yes, but the current issue with this homework assignment is that the program needs to be able to input r and h and call the overloaded class functions with either int, float or double arguments. So...
-
This follows from my question in post #50. How are you going to have the user input int, float or double? How are you going to test your various class overloaded functions? You can't input a...
-
So where is the code to ask the user to input radius and height? :mad: Where is
cout<<"\nEnter radius of Cylinder\n";
cin>>r;
cout<<"\nEnter height of Cylinder\n";
cin>>h;
-
What error are you getting? I tried it and it works for me.
-
:cry: No, you cannot do this. r is defined as type integer. You cannot do comparisons against type.
Again, you are guessing without understanding what you are doing. You cannot guess with c++ -...
-
In main, r and h are defined as integers. cin >> r tries to get an integer and reads 3. cin >> h tries to read another integer but finds . which isn't a digit so the cin fails. Hence h hasn't been...
-
As GCDEF said, much improved:thumb:. Your class calculate now has various overloaded functions for cylinder_area and cylinder_volume. So from you main function, how are you going to allow the user to...
-
-
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...
-
default:
cout<<"\nThe choice entered is a wrong choice";
cout<< "Area =" << c.area() << "\n";
cout<< "Volume=" << c.volume() << "\n";
So you are only going to calculate the...
-
Well you're getting closer!
In your case statements, you haven't actually called the class functions! So in case 1 for example you need
cin>>y;
cout << "Area is: " << c.area(x, y) << endl;
-
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...
-
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...
-
Re b). Please re-read Nuzzle's post #8 re polymorphism and casting. This is probably to what your teacher is referring (albeit badly) - ie int into a double and float into a double. Hence only one...
-
cout <<"Enter radius\n";
cin>>r;
cout <<"Enter height\n";
cin>>h;
Where have you defined the variables r and h??
Also note that 3.14 * r * r is not the formula for the surface area of a...
-
b)Just because the radius and height input from the keyboard can be either an integer, float or double does not mean that you require 3 different functions to calculate the area and 3 different...
-
If you are going to overload a function, the compiler must be able to differentiate between the various overloaded functions to determine the one to use. Simplified, it matches the number and type of...
-
Please when you post code format your code properly first and use code tags. Go Advanced, select code and click '#'. Your code is pretty unreadable without.
-
I might be useful if you posted what I asked in post #7.
If you need to input r and h from the keyboard as either int, float or double, then you have three choices. a) Ask the user whether they...
-
April 28th, 2013, 10:28 AM
-
April 28th, 2013, 10:06 AM
-
April 27th, 2013, 09:04 AM
It might be useful if you said exactly what your assignment is because if you are trying to use polymorphism then you use base and derived classes with inheritance. So if your teacher hasn't covered...
-
April 27th, 2013, 08:49 AM
Polymorphism is to do with derived classes from a base class. So what's your base class definition and what are your derived classes?
-
April 27th, 2013, 08:11 AM
First, do you know the formula for calculating the surface area and volume in terms of radius and height? Why do you want to do it for integer, float and double? Why not just double?
|
Click Here to Expand Forum to Full Width
|