Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jan 27th, 2008, 11:40 AM   #1
zanatos
Newbie
 
Join Date: Dec 2007
Posts: 11
Rep Power: 0 zanatos is on a distinguished road
Importing classes!

I am making a small program that will use the quadratic equation to solve a problem. I am suppose to make two separete classes, one to ask for input(main method) and the other to calcuate. So far I made both classes and wrote the code. However, I am having problems importing the second class and calling it! I know I have to write this import classname; but how do I call the class? so it can do its function.

Thx in advance.
zanatos is offline   Reply With Quote
Old Jan 27th, 2008, 12:49 PM   #2
Eric the Red
Hobbyist Programmer
 
Eric the Red's Avatar
 
Join Date: Feb 2006
Posts: 214
Rep Power: 0 Eric the Red is an unknown quantity at this point
Re: Importing classes!

If you've got 2 classes / 2 separate files. You'll be able to instantiate an instance of your calculate class (from within your other class) Done like so ->

Calculate calc = new Calculate();

Furthermore, if you want to call methods from that class you do

int theValue = 0;
theValue = calc.calculateIT();
__________________
Death smiles at us all. All a man can do is smile back.
Eric the Red is offline   Reply With Quote
Old Jan 27th, 2008, 4:34 PM   #3
zanatos
Newbie
 
Join Date: Dec 2007
Posts: 11
Rep Power: 0 zanatos is on a distinguished road
Re: Importing classes!

Thanks alot, it works great!
zanatos is offline   Reply With Quote
Old Jan 28th, 2008, 10:36 PM   #4
Eric the Red
Hobbyist Programmer
 
Eric the Red's Avatar
 
Join Date: Feb 2006
Posts: 214
Rep Power: 0 Eric the Red is an unknown quantity at this point
Re: Importing classes!

Not a problem. Good luck!
__________________
Death smiles at us all. All a man can do is smile back.
Eric the Red is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Importing a file using VB u2cannv Visual Basic 3 Oct 22nd, 2007 2:48 PM
Importing a SWF into another Flash file grimpirate Other Web Development Languages 0 Sep 18th, 2006 12:35 AM
Importing from DLL's on Unix Kaja Fumei Existing Project Development 5 Jan 9th, 2006 6:35 PM
About importing your projects 357mag C++ 8 Apr 22nd, 2005 7:59 AM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 3:08 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC