Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

sharpgames

What's wrong with this code?

This topic is 5246 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Try to compile test 1 & 2. Here''s the link. I renamed it to jpg because that''s the only thing my upload service will let me upload. So just right click download and rename to zip. http://www.boomspeed.com/hellyeah17/Dunno.jpg

Share this post


Link to post
Share on other sites
Advertisement
TEST 1

// Fig. 9.7: fig09_07.cpp
// Demonstrate when base-class and derived-class
// constructors and destructors are called.
#include

#include "point2.h"
#include "circle2.h"

int main()
{
// Show constructor and destructor calls for Point
{
Point p( 11, 22 );
}

cout << endl;
Circle circle1( 4.5, 72, 29 );
cout << endl;
Circle circle2( 10, 5, 5 );
cout << endl;
return 0;
}








TEST 2


// Fig. 9.10: fig09_10.cpp
// Driver for class Cylinder
#include

#include "point2.h"
#include "circle2.h"
#include "cylindr2.h"

int main()
{
// create Cylinder object
Cylinder cyl( 5.7, 2.5, 12, 23 );

// use get functions to display the Cylinder
cout << "X coordinate is " << cyl.getX()
<< "\nY coordinate is " << cyl.getY()
<< "\nRadius is " << cyl.getRadius()
<< "\nHeight is " << cyl.getHeight() << "\n\n";
// use set functions to change the Cylinder''s attributes
cyl.setHeight( 10 );
cyl.setRadius( 4.25 );
cyl.setPoint( 2, 2 );
cout << "The new location, radius, and height of cyl are:\n"
<< cyl << ''\n'';

cout << "The area of cyl is:\n"
<< cyl.area() << ''\n'';

// display the Cylinder as a Point
Point &pRef = cyl; // pRef "thinks" it is a Point
cout << "\nCylinder printed as a Point is: "
<< pRef << "\n\n";

// display the Cylinder as a Circle
Circle &circleRef = cyl; // circleRef thinks it is a Circle
cout << "Cylinder printed as a Circle is:\n" << circleRef
<< "\nArea: " << circleRef.area() << endl;

return 0;
}

Share this post


Link to post
Share on other sites
why do u have a random #include at the top?

btw, the [.source] [./source] tags (without the .) are the prefered way for ppl to post large(ish) amounts of code, for small sections the [.code] [./code] tags are the other option

Share this post


Link to post
Share on other sites
What''s wrong? You are too lazy, that''s what is wrong. How about at least telling us what the error is?!

Share this post


Link to post
Share on other sites
I would love to get my teeth wet and help you out. I see sevreal problems with your code already. However you need to format your output of it on this board correctly, and then you need to compile it and using the apropiate tags - let us know the compilation errors.




I don''''t believe in signatures, they are a waste of time and I would never consider having one.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I know what''s wrong with it. What do you thinks wrong with it and why?

For example

1) It won''t compile and gives the errors...

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!