I need an explanation on the basic structure of a driver for a class I've created. The header file is stored in the "header files" folder of my project, and the class is stored in the "source files" folder. This is my class' code if you want to use this to help in the explanation. Otherwise, some sort of basic structure example/description to help me understand a driver would be appreciated.
A driver is generally a piece of software that bridges between hardware and an operating system. I'm guessing you don't want one of those, so what exactly are you asking? Are you asking how you can actually use your class?
Err, yes. My professor calls it a driver (I guess incorrectly?). I would like to know the structure of the int main() function I need to have to use this class.
**I only want to know how to create the file that causes a class to operate. It doesn't have to be able to run this class. I just provided my class as an example to use.
the driver.cpp program would have a reference to your header file for your class and any other header files needed to run main.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#include "payroll.h"
#include <iostream>//most commonly used with hw assignmenst it seems...
usingnamespace std;
int main(){
payroll myPayroll; // new payroll object
myPayroll.setPayPeriod(52);//or whatever functions you want to use/create for this class
return 0;
}
the driver.cpp goes in your source code folder and you build the solution.
All of this gets compiled together and you can run the executable from your debug folder where the source is stored ( i am assuming you are using visual studio)
My professor calls it a driver (I guess incorrectly?)
Not so much incorrect as just colloquial; if its sole purpose is to drive an instance of a class, why not call it the driver. In context, it makes sense.