Click here to Skip to main content
16,006,065 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Problems with DirectX 8 SDK Pin
Gary R. Wheeler23-Oct-05 1:47
Gary R. Wheeler23-Oct-05 1:47 
GeneralRe: Problems with DirectX 8 SDK Pin
dudeua23-Oct-05 2:09
dudeua23-Oct-05 2:09 
GeneralRe: Problems with DirectX 8 SDK Pin
dudeua23-Oct-05 3:35
dudeua23-Oct-05 3:35 
QuestionHelp with a function. Pin
ericelysia23-Oct-05 0:03
ericelysia23-Oct-05 0:03 
AnswerRe: Help with a function. Pin
Mircea Puiu23-Oct-05 0:10
Mircea Puiu23-Oct-05 0:10 
GeneralRe: Help with a function. Pin
ericelysia23-Oct-05 0:25
ericelysia23-Oct-05 0:25 
GeneralRe: Help with a function. Pin
Mircea Puiu23-Oct-05 1:33
Mircea Puiu23-Oct-05 1:33 
GeneralRe: Help with a function. Pin
ericelysia23-Oct-05 3:32
ericelysia23-Oct-05 3:32 
OK, after tracing my code, I have fixed my previous problems (I think).

As of now, my two main concerns are:
1.) Making sure I convert the ints to floats correctly (where needed).
2.) Figuring out what is going on with my destructor (this is all new to me).

Every time I run the program with the destructor, I get an ENTERNAL COMPILER ERROR.

I really appreciate the feedback and suggestions!

Thanks,
Eric

Here is my program:
<br />
//---------------------------------------------------------------------------<br />
//------------------------Header.h---------------------------------------<br />
<br />
#ifndef HEADER_H<br />
#define HEADER_H<br />
<br />
<br />
class Car<br />
{<br />
	public:<br />
		Car();<br />
		Car( int, string, string, string, string, int );<br />
		//~Car();<br />
		<br />
		void setYear( int );<br />
		void setManufacturer( string );<br />
		void setModel( string );<br />
		void setColor( string );<br />
		void setCondition( string );<br />
		void setOdometer( int );<br />
<br />
		int getYear();<br />
		string getManufacturer();<br />
		string getModel();<br />
		string getColor();<br />
		string getCondition();<br />
		int getOdometer();<br />
		<br />
		void printYear();<br />
		void printManufacturer();<br />
		void printModel();<br />
		void printColor();<br />
		void printCondition();<br />
		void printOdometer();<br />
<br />
		int getMinutes();<br />
		int getSpeed();<br />
<br />
		void drive( int, int );<br />
		void newCar();<br />
		void displayOdometer();<br />
		void reset();<br />
		void setCar( int, string, string, string, string, int );<br />
		void printCar();<br />
<br />
	private:<br />
		int year;<br />
		string manufacturer;<br />
		string model;<br />
		string color;<br />
		string condition;<br />
		int odometer;<br />
		int speed;<br />
		int minutes;<br />
<br />
};<br />
<br />
#endif<br />
<br />
<br />
//--------------------------------------------------------------------------------<br />
//-------------------------Implementation.cpp------------------------------<br />
<br />
#include <iostream><br />
#include <iomanip><br />
#include <string><br />
<br />
using namespace std;<br />
<br />
#include "Header.h"<br />
<br />
Car::Car()<br />
{<br />
	system( "CLS" );<br />
<br />
	year = 9999;<br />
	manufacturer = "NoManufacturerYet";<br />
	model = "NoModelYet";<br />
	color = "NoColorYet";<br />
	condition = "NoConditionYet";<br />
	odometer = 999999999;<br />
}<br />
<br />
Car::Car( int newYear, string newManufacturer, string newModel, string newColor, string newCondition, int newOdometer )<br />
{<br />
	system( "CLS" );<br />
<br />
	year = newYear;<br />
	manufacturer = newManufacturer;<br />
	model = newModel;<br />
	color = newColor;<br />
	condition = newCondition;<br />
	odometer = newOdometer;<br />
}<br />
<br />
/*<br />
Car::~Car<br />
{<br />
	cout << "\n\n  The destructor has been called.\n\n";<br />
}<br />
*/<br />
<br />
void Car::setYear( int yr )<br />
{<br />
	system( "CLS" );<br />
<br />
	year = yr;<br />
}<br />
<br />
void Car::setManufacturer( string manufact )<br />
{<br />
	system( "CLS" );<br />
<br />
	manufacturer = manufact;<br />
}<br />
<br />
void Car::setModel( string mod )<br />
{<br />
	system( "CLS" );<br />
<br />
	model = mod;<br />
}<br />
<br />
void Car::setColor( string col )<br />
{<br />
	system( "CLS" );<br />
<br />
	color = col;<br />
}<br />
<br />
void Car::setCondition( string con )<br />
{<br />
	system( "CLS" );<br />
<br />
	condition = con;<br />
}<br />
<br />
void Car::setOdometer( int odom )<br />
{<br />
	system( "CLS" );<br />
<br />
	odometer = odom;<br />
}<br />
<br />
int Car::getYear()<br />
{<br />
	system( "CLS" );<br />
<br />
	return year;<br />
}<br />
<br />
string Car::getManufacturer()<br />
{<br />
	system( "CLS" );<br />
<br />
	return manufacturer;<br />
}<br />
<br />
string Car::getModel()<br />
{<br />
	system( "CLS" );<br />
<br />
	return model;<br />
}<br />
<br />
string Car::getColor()<br />
{<br />
	system( "CLS" );<br />
<br />
	return color;<br />
}<br />
<br />
string Car::getCondition()<br />
{<br />
	system( "CLS" );<br />
<br />
	return condition;<br />
}<br />
<br />
int Car::getOdometer()<br />
{<br />
	system( "CLS" );<br />
<br />
	return odometer;<br />
}<br />
<br />
void Car::printYear()<br />
{<br />
	//system( "CLS" );<br />
<br />
	cout <<"\n\n  Year: " << year;<br />
}<br />
<br />
void Car::printManufacturer()<br />
{<br />
	//system( "CLS" );<br />
<br />
	cout <<"\n\n  Manufacturer: " << manufacturer;<br />
}<br />
<br />
void Car::printModel()<br />
{<br />
	//system( "CLS" );<br />
<br />
	cout <<"\n\n  Model: " << model;<br />
}<br />
<br />
void Car::printColor()<br />
{<br />
	//system( "CLS" );<br />
<br />
	cout <<"\n\n  Color: " << color;<br />
}<br />
<br />
void Car::printCondition()<br />
{<br />
	//system( "CLS" );<br />
<br />
	cout <<"\n\n  Condition: " << condition;<br />
}<br />
<br />
void Car::printOdometer()<br />
{<br />
	//system( "CLS" );<br />
<br />
	cout <<"\n\n  Odometer: " << odometer;<br />
}<br />
<br />
int Car::getSpeed()<br />
{<br />
	system( "CLS" );<br />
<br />
	cout << "\n\n  Please enter the speed you drove the car: ";<br />
	cin >> speed;<br />
<br />
	return speed;<br />
}<br />
<br />
int Car::getMinutes()<br />
{<br />
	system( "CLS" );<br />
<br />
	cout << "\n\n  Please enter the number of minutes you drove the car: ";<br />
	cin >> minutes;<br />
<br />
	return minutes;<br />
}<br />
<br />
void Car::drive( int spd, int minutes )<br />
{<br />
	int miles;<br />
<br />
	system( "CLS" );<br />
<br />
	miles = ( ( spd * minutes ) / 60 );<br />
	odometer += miles;<br />
<br />
	cout << "\n\n  The speed you entered is " << speed << ".";<br />
	cout << "\n\n  The number of minutes you entered is " << minutes << " minutes.";<br />
	cout << "\n\n  The milage added to the odometer is " << miles << ".";<br />
<br />
	cout << "\n\n Press Enter to continue.";<br />
	cin.get();<br />
}<br />
<br />
void Car::newCar()<br />
{<br />
	system( "CLS" );<br />
<br />
	cout << "\n  Please enter the year of the car: ";<br />
	cin >> year;<br />
	cout << "\n  Please enter the manufacturer of the car: ";<br />
	cin >> manufacturer;<br />
	cout << "\n  Please enter the model of the car: ";<br />
	cin >> model;<br />
	cout << "\n  Please enter the color of the car: ";<br />
	cin >> color;<br />
	cout << "\n  Please enter the condition of the car: ";<br />
	cin >> condition;<br />
	cout << "\n  Please enter the milage (odometer) of the new car: ";<br />
	cin >> odometer;<br />
<br />
	setCar( year, manufacturer, model, color, condition, odometer );<br />
}<br />
<br />
void Car::displayOdometer()<br />
{<br />
	system( "CLS" );<br />
<br />
	cout << "\n  The odometer is at " << odometer << ".";<br />
}<br />
<br />
void Car::reset()<br />
{<br />
	system( "CLS" );<br />
<br />
	year = 0;<br />
	manufacturer = "";<br />
	model = "";<br />
	color = "";<br />
	condition = "";<br />
	odometer = 0;<br />
<br />
	cout << "\n\n  The car attributes have been reset.\n";<br />
}<br />
<br />
void Car::setCar( int year, string manufacturer, string model, string color, string condition, int odometer )<br />
{<br />
	system( "CLS" );<br />
}<br />
<br />
void Car::printCar()<br />
{<br />
<br />
	printYear();<br />
	printManufacturer();<br />
	printModel();<br />
	printColor();<br />
	printCondition();<br />
	printOdometer();<br />
}<br />
<br />
<br />
//--------------------------------------------------------------------------<br />
//-------------------------------Main.cpp--------------------------------<br />
<br />
#include <iostream><br />
<br />
using namespace std;<br />
<br />
#include "Header.h"<br />
<br />
int main()<br />
{<br />
	Car c;<br />
	<br />
	char choice;<br />
	do<br />
	{	<br />
		cout << "\n\n\n  Please make a selection from the menu.\n\n";<br />
		cout << "\n  Press 'A' to add milage to the odometer.\n";<br />
		cout << "\n  Press 'C' to clear the screen.\n";<br />
		cout << "\n  Press 'D' to display the car attributes.\n";<br />
		cout << "\n  Press 'N' to add new/used car attributes.\n";<br />
		cout << "\n  Press 'O' to display the odometer.\n";<br />
		cout << "\n  Press 'R' to reset the car attributes.\n";<br />
		cout << "\n  Press 'X' to exit the program.\n";<br />
<br />
		cin >> choice;<br />
		choice = toupper( choice );<br />
<br />
		switch( toupper( choice ) )<br />
		{<br />
			case 'A':	c.drive( c.getSpeed(), c.getMinutes() );<br />
						break;<br />
			<br />
			case 'C':	system( "CLS");<br />
						break;<br />
<br />
			case 'D':	c.printCar();<br />
						break;<br />
<br />
			case 'N':	c.newCar();<br />
						break;<br />
<br />
			case 'O':	c.displayOdometer();<br />
						break;<br />
<br />
			case 'R':	c.reset();<br />
						break;<br />
		<br />
			case 'X':	break;<br />
		<br />
			default:	cout << "\n Unknown choice entered.\n"<br />
							 << " Enter a new choice.\n\n";<br />
						break;<br />
		}<br />
	<br />
	} while ( choice != 'X' );<br />
<br />
	cout << "\n\n\n  ";<br />
<br />
	return 0;<br />
}<br />


-- modified at 11:04 Sunday 23rd October, 2005
GeneralRe: Help with a function. Pin
ericelysia23-Oct-05 5:10
ericelysia23-Oct-05 5:10 
GeneralRe: Help with a function. Pin
ericelysia23-Oct-05 5:30
ericelysia23-Oct-05 5:30 
Questionclistctrl grouping Pin
huby8922-Oct-05 22:54
huby8922-Oct-05 22:54 
AnswerRe: clistctrl grouping Pin
Mircea Puiu23-Oct-05 0:08
Mircea Puiu23-Oct-05 0:08 
AnswerRe: clistctrl grouping Pin
Gary R. Wheeler23-Oct-05 1:08
Gary R. Wheeler23-Oct-05 1:08 
GeneralRe: clistctrl grouping Pin
huby8923-Oct-05 8:37
huby8923-Oct-05 8:37 
GeneralRe: clistctrl grouping Pin
PJ Arends23-Oct-05 10:13
professionalPJ Arends23-Oct-05 10:13 
GeneralRe: clistctrl grouping Pin
huby8924-Oct-05 6:26
huby8924-Oct-05 6:26 
GeneralRe: clistctrl grouping Pin
PJ Arends24-Oct-05 9:55
professionalPJ Arends24-Oct-05 9:55 
Questioni want to learn visual C++ 6 Pin
knowledgelover22-Oct-05 20:04
knowledgelover22-Oct-05 20:04 
AnswerRe: i want to learn visual C++ 6 Pin
Ravi Bhavnani22-Oct-05 20:28
professionalRavi Bhavnani22-Oct-05 20:28 
GeneralRe: i want to learn visual C++ 6 Pin
knowledgelover22-Oct-05 21:41
knowledgelover22-Oct-05 21:41 
AnswerRe: i want to learn visual C++ 6 Pin
Mike Angel Martin23-Oct-05 3:54
Mike Angel Martin23-Oct-05 3:54 
Questioni want to learn visual C++ 6 Pin
knowledgelover22-Oct-05 20:03
knowledgelover22-Oct-05 20:03 
AnswerRe: i want to learn visual C++ 6 Pin
Anonymous23-Oct-05 17:19
Anonymous23-Oct-05 17:19 
Questionrookie question Pin
Binary011022-Oct-05 17:43
Binary011022-Oct-05 17:43 
AnswerRe: rookie question Pin
Anonymous22-Oct-05 18:55
Anonymous22-Oct-05 18:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.