![]() |
|
#1
|
|||
|
|||
Assistance with classes...Hello all...
I was given the following project to complete: Write the declarations and definitions for the geometric classes defined in Figure 12-21. Use the following hints: a.Define Shape, Two-Dimensional and Three-Dimensional as abstract classes. b.Define PI as static class member in the Shape class. c.Define area calculation and print functions as pure virtual functions in the Shape class. d.Use public inheritance. e.Define all data or member functions common to two-dimensional shapes in the Two-dimensional class. Do the same for all common data or member functions for the three-dimensional shape. Figure 12-21 Shape: -Two Dimensional Triangle Rectangle Circle -Three Dimensional Cone Cube Sphere I have a clear understanding of what to do with the two dimensional class...its the three dimensional class I'm having trouble with. If there is anyone that can provide me with some direction I would really appreciate. Thanks! |
|||
|
#2
|
|||
|
|||
|
What's the difficulty?
Two dimensional is area, square inches, square feet, square meters... Three dimensional is volume. Cubic inches, cubic centimeters, etc. Maybe your first step would be to write out eh formulas and characteristics of each shape? (example) Triangle: Sides - 3 Enclosed angle - 180 degrees Primary measurements: Base * height Area calculation: 1/2 * base * height |
|
#3
|
|||
|
|||
|
mhmm...that makes alot more sense...create an algorithm.
Thanks! |
|
#4
|
|||
|
|||
Errors...Ok, I am now running into three errors now that I have compiled the program...I don't know what they mean though. Heres the program:
CPP / C++ / C Code:
I believe that it has something to do with the integer "a" that I implemented...but I don't know how do go about correcting it. Can anyone help? Last edited by LuciWiz : 28-Apr-2005 at 17:59.
Reason: Please insert your C++ code between [c++] & [/c++] tags
|
|
#5
|
||||
|
||||
|
Read the sticky. Read the sticky. Read the sticky.
It's not hard to find. It's at the top of the forum with the useful title Guidelines for posting requests for help __________________
During the election they said Obama could only be elected when pigs fly. Well, we currently have an epidemic of Swine Flu. Coincidence? |
|
#6
|
|||
|
|||
I apologize...Quote:
CPP / C++ / C Code:
|
|
#7
|
|||
|
|||
|
This is not my strong suit, but I'll give it a whirl.
http://www.parashift.com/c++-faq-lit....html#faq-22.4 Your Cube is a public three_dim, which has a pure virtual function calcVol; so Cube must define one. You do that, okay. Your three_dim is a public shape, which has pure virtual functions calcArea and print; so you must define them for Cube as well. You don't: problem. So if you add these to Cube: CPP / C++ / C Code:
CPP / C++ / C Code:
CPP / C++ / C Code:
CPP / C++ / C Code:
CPP / C++ / C Code:
|
|
#8
|
|||
|
|||
Thanks!Thank you soo much! That helped alot...as well as the link.
I appreciate it! Quote:
|
Recent GIDBlog
Toyota - 2009 May Promotion by Nihal
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Help using const arrays in c++ classes | FlipNode | C++ Forum | 5 | 31-Mar-2005 02:16 |
| bug w/ templated classes | f15e | MS Visual C++ / MFC Forum | 4 | 07-Mar-2005 00:56 |
| Fairly simple classes help please | sammacs | C++ Forum | 0 | 30-Nov-2004 10:58 |
| ClassView not showing my classes (VC++, namespace, headers) ?!?!? | djovanov | C++ Forum | 1 | 13-Jan-2004 05:54 |
| using windows WMI and CMI classes in Dev-c++ | Dawis | C++ Forum | 0 | 26-Oct-2003 05:18 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The