Go Back   PCMech Forums > Help & Discussion > Web Design / Development

Need Some Help? Type Your Keywords Here:

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old 04-11-2003, 07:02 PM   #1
Member (8 bit)
 
Join Date: Aug 1999
Location: Florida
Posts: 237
Send a message via AIM to revelation
Stubs and Drivers?

Hello,
As I have mentioned in other threads, I am right in the middle of a class on C++. We just covered a short section on stubs and drivers. I am unclear as to how these are written, how they are used and why. Maybe someone can put this concept into a different perspective.

As my boss said when I said I had a stupid question for him, "there is no such thing as a stupid question, just stupid people"...I hope this does not apply here ;-)
revelation is offline   Reply With Quote
Old 04-14-2003, 11:35 PM   #2
Member (7 bit)
 
LoveJones's Avatar
 
Join Date: Sep 2002
Posts: 93
Hey, we all knew squat at one point.

A stub is basically a place holder for a function or method that you know you will need. It's part reminder, part making the compiler happy in some cases.

For example, you know you are going to need an insert method, so remind yourself by throwing a stub into your .h file and throw a declaration in the source code.

For example...

class Person {
public:
Person( ) //defined in source code
~Person( ) //defined in source code
void insert( int x );
private:
string name;
int age;
int weight;
}

And in the source code you'd have the function...


void insert( int x )
{
**insert's code**
}

So you see, it's nothing more than a placeholder, sometimes neccesary to make the skeleton of the program.



Ok, as for a driver, it is basically the implementation of other classes and it's methods.

I know that doesn't sound concrete, but let me try to make an example.

Say I wrote my Person class, and I wrote all the source codes for the methods in the Person class. By itself, that code doesn't do a whole lot. It just sits there looking pretty waiting to be used. That's where the driver comes in. It actually implements that source code towards something useful.

All you need to do is #include "person.h", assuming that's what we called the above .h file.

I hope that helps, please don't be afraid to ask if some things aren't clear!

LoveJones is offline   Reply With Quote
Old 04-15-2003, 09:01 AM   #3
Member (8 bit)
 
Join Date: Aug 1999
Location: Florida
Posts: 237
Send a message via AIM to revelation
Thanks!! That does help. That is exactly what the stubs and drivers do in the program we are doing for a project. Right now they don't do much but they "hold the place" for when they are needed in chapters to come.

I am sure I will be back here with more questions. Next week is the final for this term and the following week we begin a new term. It will pick up where we left off.
revelation is offline   Reply With Quote
Reply

Bookmarks

Still Need Help? Type Your Keywords Here:


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 07:57 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 PL2