home hardware prices news articles forums photos user reviews
Go Back   Tech Support Forums - TechIMO.com > PC Hardware and Tech > Webmastering and Programming
Ask a Tech Support Question (free)!

simple c++ library help

Reply
Get bargains at  »  Dealighted.com
 
Thread Tools Search this Thread
Currently Active Users: 2442
Discussions: 200,941, Posts: 2,379,275, Members: 246,304
Old November 16th, 2004, 02:29 AM   Digg it!   #1 (permalink)
Member
 
Join Date: Nov 2004
Posts: 56
simple c++ library help

this is the problem

Write a C++ program that reads the radius and height of a sphere in centimeters (real) from an input file (prog6b.inp), calculates the surface area and volume of the sphere and prints the input values plus the calculated values to an output file (prog6b.out).

Processing:
Program 6 is to read the radius and height of the sphere from prog6b.inp.
A function should be called to calculate the surface area of the sphere.
(surface area = 4*PI * radius2)
A function should be called to calculate the volume of the sphere.
(volume = 1/3 * PI * radius2 * height

Place the two functions in a library called sphere.


i wrote these notes in class,

a library has 3 files:

Clientwhich includes)
1.documentation
2.# include *.h
3.function call

Headerwhich includes)
1.documentation
2.protoypes

Implementationincludes)
1.documentation
2.# include
3.function definition

now i have this information and i know what it is, i just dont know what to do with it, like how to make it a library. I'm using dev c++ v4.o

thanks
sirhc
boogieman063 is offline   Reply With Quote
Old November 17th, 2004, 02:30 PM     #2 (permalink)
Ultimate Member
 
elmers's Avatar
 
Join Date: Sep 2003
Location: Philadelphia
Posts: 1,484
Ok the client is the program where you include your header file. The header file is connected to the implementation file.

The header file might contain a prototype or a header, something like this:

int add(int x, int y);

The implemenation is where you flesh out your functions like this

int add(int x, int y)
{
return x+y;
}

You can have anything in the implementation file but only the functions declared in the header file can be imported into other files(ie client files).

What you need is to first write and debug the functions as you would in any ordinary program with one file. Then once youre sure the foos work you copy the code into a
hdr.c file which is you implementation file. Then you write a hdr.h file with just the prototypes (only the first line of a function without the {} and stuff between them, followed by a ";".

Then you go #include "hdr.h" and write another file. Becuase theyre in your hdr.c file which you included in your main program file you dont need to rewrite the foos, just use them as if they were there.

BTW, this is from memory, might be a few syntax errors.
elmers is offline   Reply With Quote
Old November 17th, 2004, 03:06 PM     #3 (permalink)
Space for Sale! :p
 
eagle1's Avatar
 
Join Date: Oct 2001
Location: La Isla del Encanto
Posts: 5,836
Are you planning to learn something?
Or just pass the class and forget about everything?



I suggest you read the material (as it seems this is for a class assignment) provided and try to tackle the program by yourself.
Provide the code you have so at least we don't have to give you everything that way and just help you in tough spots!
__________________
boo!
eagle1 is offline   Reply With Quote
Old November 17th, 2004, 03:12 PM     #4 (permalink)
Member
 
Join Date: Nov 2004
Posts: 56
there is no material, just the notes we take in class, no text, i just forgot what the prof had told us to do with the files, and i'm not asking for the whole thing, just the part about the library. thanks elmers, that stuff u replied with does ring a bell.
boogieman063 is offline   Reply With Quote
Old November 17th, 2004, 07:03 PM     #5 (permalink)
Ultimate Member
 
elmers's Avatar
 
Join Date: Sep 2003
Location: Philadelphia
Posts: 1,484
ygpm boog
elmers is offline   Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Similar Threads
Thread Thread Starter Forum Replies Last Post
Funny George Bush Pics! shawshank62 IMO Community 30 March 1st, 2005 09:23 AM
error 2337 when installing visual studio .net wetdog500 Webmastering and Programming 14 October 6th, 2003 06:53 PM
Have you ever donated your books to a Library? SiliconJon IMO Community 6 September 4th, 2003 11:19 PM
E17 CVS Compile Errors ChoaticWhisper Applications and Operating Systems 6 July 14th, 2002 03:55 AM
What would I use? CSS? BITM@D Webmastering and Programming 12 April 11th, 2002 06:52 AM


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Most Active Discussions
Is It Just Me? (2916)
windows 7 problem (7)
CPU fan stops spinning randomly (8)
Wireless Televisions. (8)
California Passes Anti-Flat-HDTV Le.. (43)
Regular Build (6)
Obama the Muslim (14)
Is the PSU I received dead? (11)
HIS HD5770 graphic card question (15)
windows vista security holes (9)
Install XP pro and a Vista laptop ?.. (11)
Print spooler problem (13)
Foreign voltage (10)
Dept. of HS: NSA 'Helped' Develop V.. (15)
Recent Discussions
radeon x850xt platinum & shader 3 (4)
screen resolution vs monitor size (1)
sms storage to PC (0)
Regular Build (6)
Open With ..... Win7 (0)
java code for fibonacci (1)
[F@H SPAM 11/16/09] ! 1/2 months to r.. (35)
windows 7 problem (7)
CPU fan stops spinning randomly (8)
Partition Magic caused HDD problem (3)
Is the PSU I received dead? (11)
Have you switched yet? (85)
Point and Shoot Camera Suggestions. (2)
Modern Warfare 2 freeze (13)
Wireless Televisions. (8)
wireless user (1)
World's largest Monopoly Game using G.. (332)
Ideal cheap graph card for PC-Gaming? (17)
BIOS won't read disk when I try to fl.. (0)
Install XP pro and a Vista laptop ?? (11)
Graphics Card Upgrade Question (1)
favorit (1)
solutions for virtical white lines on.. (1)
Fire in DVD (2)
Modern Warfare For the PC (33)


All times are GMT -4. The time now is 02:38 PM.
TechIMO Copyright 2009 All Enthusiast, Inc.



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28