2010 Lab-15
Lab elements include:
• Classes
• Base class
• Derived classes
• Display of images
Getting started Start with your base.cpp program from Monday class. base.cpp program is here: /home/fac/gordon/public_html/2010/base.cpp Copy it to 2010/f/vehicles.cpp
Vehicle base class and derived classes You will have a startup menu that looks like the following.Lab-15 Vehicles Menu -------------------- 1. Display vehicle-1 2. Display vehicle-2 3. Diisplay vehicle-3 4. Display all vehicles 0. Quit programNote: Replace vehicle-1, 2, etc. with the names of your vehicles. Demonstrate the class when menu items are chosen. format of output:Vehicle-1 statistics: Number of passengers: nnn License number: ABC123 See image. Vehicle-2 statistics: Number of passengers: nnn Marine ID: MAR-12334-01-A1 See image.
display.cpp program
#include <unistd.h>
#include <signal.h>
#include <iostream>
using namespace std;
char **myenvp;
int main(int argc, char *argv[], char *envp[]) {
myenvp = envp;
//system("display boat.jpg");
int child = fork();
if (child == 0) {
//the child
//system("display boat.jpg");
char *arg[] = {(char *)"/usr/bin/display",
(char *)"boat.jpg",
NULL};
execve(arg[0], arg, myenvp);
}
cout << "Enter a number: ";
int num;
cin >> num;
kill(child, SIGKILL);
return 0;
}