Car::Car(int YearofModel, string Makeby, int Spd)
{
YearModel = YearofModel;
Make = Makeby;
Speed = Spd;
}
void displayMenu()
{
cout <<"\n Menu\n";
cout << "----------------------------\n";
cout << "A)Accelerate the Car\n";
cout << "B)Push the Brake on the Car\n";
cout << "C)Exit the program\n\n";
cout << "Enter your choice: ";
}
===========================================
Below is an excerpt from automobile.cpp that has main()
#include "stdafx.h" // Defines IDE required external definition files
#include <iostream> // Defines objects and classes used for stream I/O
// Class Definition header file(s)
#include "Car.h"
#include <string.h>
// Namespaces utilized in this program
using namespace std; // Announces to the compiler that members of the namespace "std"
// are utilized in this program
int main()
{
char choice; //Menu selection
cout << "The speed of the SUV is set to: " << Speed <<endl;
Car first( 2007, "GMC", Speed);
//Display the menu and get a valid selection
do
{
displayMenu();
===========================
So call to displayMenu above receives an error message that it's undefined.
Do I have to do something in the header file?
Not sure how your compiler works but the one I use I need to put all my header files in the compilers library/include folder so it knows where to find it.
If its not that then sorry I couldn't be of more help.
When your automobile.cpp file is being compiled, the compiler doesn't see the declaration for displayMenu. Not clear if there is one, since you didn't post car.h.
PLEASE USE CODE TAGS (the <> formatting button) when posting code.