Click here to Skip to main content
15,909,656 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: detect if download? Pin
David Crow30-Aug-04 4:56
David Crow30-Aug-04 4:56 
GeneralWired Message Routing Problem Pin
pma28-Aug-04 12:37
pma28-Aug-04 12:37 
GeneralNon-printable characters Pin
kfaday28-Aug-04 11:24
kfaday28-Aug-04 11:24 
GeneralRe: Non-printable characters Pin
Ravi Bhavnani28-Aug-04 11:35
professionalRavi Bhavnani28-Aug-04 11:35 
GeneralRe: Non-printable characters Pin
kfaday28-Aug-04 13:15
kfaday28-Aug-04 13:15 
Generalconfuse multiple source and header file Pin
badbirdchung28-Aug-04 9:17
badbirdchung28-Aug-04 9:17 
GeneralRe: confuse multiple source and header file Pin
Joaquín M López Muñoz28-Aug-04 9:28
Joaquín M López Muñoz28-Aug-04 9:28 
GeneralRe: confuse multiple source and header file Pin
badbirdchung28-Aug-04 10:29
badbirdchung28-Aug-04 10:29 
Hi,

Thanks your reply. But I still have problem when I compile car.cpp file and below is detail information of car.h, car.cpp, engine.h and engine.cpp. Can you help me again, many thanks.

engine.h file
#ifndef ENGINE_H
#define ENGINE_H
Confused | :confused:
class Engine {
public:
Engine();
Engine(double p, double w, double price, double maxp);
~Engine();

double GetPower();
double GetWeight();
double GetPrice();
double GetMaxPower();
protected:
double mPower;
double mWeight;
double mPrice;
double mMaxPower;

};

#endif

engine.cpp file
#include <iostream.h>
#include "engine.h"

Engine::Engine(){
mPower = 0 ; mWeight = 0 ; mPrice = 0 ; mMaxPower = 0;
}

Engine::Engine(double p, double w, double price, double maxp){
mPower = p;mWeight = w;mPrice = price;mMaxPower = maxp;
}

Engine::~Engine(){

}

double Engine::GetPower(){
return mPower;
}

double Engine::GetWeight(){
return mWeight;
}

double Engine::GetPrice(){
return mPrice;
}

double Engine::GetMaxPower(){
return mMaxPower;
}

Car.h file
#ifndef CAR_H
#define CAR_H

#include "engine.h"
#include "gearbox.h"
#include "carbody.h"

class Car{
public:
Car();
Car(Engine& e, GearBox& g, CarBody& b);
~Car();

double GetWeight();
double GetPrice();
double GetMaxSpeed();
void SpeedUp();
void SpeedDown();
double GetCurrentSpeed();

protected:
double mCurrentSpeed;
double mMaxSpeed;
double mWeight;
double mPrice;
Engine mEngine;
GearBox mGearBox;
CarBody mCarBody;

void UpdateWeight();
void UpdatePrice();
void UpdateMaxSpeed();
};

#endif


Car.cpp file
#include <iostream.h>
#include "car.h"

Car::Car(){
mCurrentSpeed = 0 ; mMaxSpeed = 0 ; mWeight = 0 ; mPrice = 0;
}

Car::Car(Engine& e, GearBox& g, CarBody& b){
mEngine = e ; mGearBox = g ; mCarBody = b;
}

Car::~Car(){

}

void Car::UpdateWeight(){

double mWeight=Engine.GetWeight();
}

But when I compile only car.cpp file and it point to "double mWeight=Engine.GetWeight" and display below error message.

Compiling...
Car.cpp
F:\c++\My05\Car.cpp(18) : error C2275: 'Engine' : illegal use of this type as an expression
f:\c++\my05\engine.h(4) : see declaration of 'Engine'
GeneralRe: confuse multiple source and header file Pin
markkuk28-Aug-04 11:55
markkuk28-Aug-04 11:55 
GeneralRe: confuse multiple source and header file Pin
bneacetp28-Aug-04 9:35
bneacetp28-Aug-04 9:35 
Questionhow to write text to RichEdit line by line Pin
siripod surabotsophon28-Aug-04 5:48
siripod surabotsophon28-Aug-04 5:48 
AnswerRe: how to write text to RichEdit line by line Pin
toxcct28-Aug-04 7:24
toxcct28-Aug-04 7:24 
QuestionHow can i detect the the Program Files Folder Pin
zahid_ash28-Aug-04 1:23
zahid_ash28-Aug-04 1:23 
AnswerRe: How can i detect the the Program Files Folder Pin
Mika Larramo2-Sep-04 13:01
Mika Larramo2-Sep-04 13:01 
QuestionHow can i detect the the Program Files Folder Pin
zahid_ash28-Aug-04 1:22
zahid_ash28-Aug-04 1:22 
AnswerRe: How can i detect the the Program Files Folder Pin
ThatsAlok28-Aug-04 1:48
ThatsAlok28-Aug-04 1:48 
AnswerRe: How can i detect the the Program Files Folder Pin
Larsson28-Aug-04 12:51
Larsson28-Aug-04 12:51 
GeneralRe: How can i detect the the Program Files Folder Pin
Michael Dunn28-Aug-04 13:50
sitebuilderMichael Dunn28-Aug-04 13:50 
GeneralParallell processes Pin
delis28-Aug-04 0:56
delis28-Aug-04 0:56 
GeneralRe: Parallell processes Pin
Joaquín M López Muñoz28-Aug-04 9:23
Joaquín M López Muñoz28-Aug-04 9:23 
GeneralRe: Parallell processes Pin
delis29-Aug-04 2:43
delis29-Aug-04 2:43 
GeneralRe: Parallell processes Pin
Joaquín M López Muñoz29-Aug-04 2:47
Joaquín M López Muñoz29-Aug-04 2:47 
QuestionSmart Pointers ?? Pin
zahid_ash28-Aug-04 0:35
zahid_ash28-Aug-04 0:35 
AnswerRe: Smart Pointers ?? Pin
Lim Bio Liong28-Aug-04 7:22
Lim Bio Liong28-Aug-04 7:22 
QuestionHow can I hide mouse pointer when it comes over my window Pin
Atif Mushtaq28-Aug-04 0:09
Atif Mushtaq28-Aug-04 0:09 

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.