473,397 Members | 1,949 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Error E2303 Type name expected?

Folks,
I cannot figure out why I am getting an error: Error E2303 EngineX.hpp
19: Type name expected. Here is my code. Can you please help?

#ifndef EngineX__hpp
#define EngineX__hpp

#include<iostream>
#include <cstring>
#include <cmath>
#include <sstream>
#include <fstream>

class EngineX : public Engine
{
// Define data members
int horsepower;

// define function prototypes
public:

EngineX(int hp); // Constructor with hp input
~EngineX();// Destructor
std::string name(); // returns engine name
double torque(double rpm, double fuelRate);// returns engine torque
};
#endif

#include <cstring>
#include <cmath>
#include<iostream>
#include <fstream>
#include <vector>
#include <iomanip>
#include <sstream>
#include "EngineX.hpp"

using namespace std;

EngineX::EngineX(int hp) // Constructor with hp input
{
horsepower = hp;
}

EngineX::~EngineX()// Destructor
{}

string EngineX::name() // returns engine name
{
stringstream ss;
ss << horsepower;
string b(ss.str());
return ("EngineX " + b + "HP");
}

double torque(double rpm, double fuelRate) // returns engine torque
{
double lrpmx = 0;
double engineTorque = 0;
double torque = 0;
lrpmx = rpm / 1000;
torque = ((-130*lrpmx*lrpmx*lrpmx) + (-600*lrpmx*lrpmx) - (791 *
lrpmx) + 2);
engineTorque = fuelRate*torque;
return engineTorque;
}
thanks very much,

Zenon
Jul 19 '05 #1
6 19173
since EngineX is a subclass of Engine the compiler needs to know about
Engine??
You probably need to include the header file that has Engine class
declaration.

"Zenon" <ze****@comcast.net> wrote in message
news:b1*************************@posting.google.co m...
Folks,
I cannot figure out why I am getting an error: Error E2303 EngineX.hpp
19: Type name expected. Here is my code. Can you please help?

#ifndef EngineX__hpp
#define EngineX__hpp

#include<iostream>
#include <cstring>
#include <cmath>
#include <sstream>
#include <fstream>

class EngineX : public Engine
{
// Define data members
int horsepower;

// define function prototypes
public:

EngineX(int hp); // Constructor with hp input
~EngineX();// Destructor
std::string name(); // returns engine name
double torque(double rpm, double fuelRate);// returns engine torque
};
#endif

#include <cstring>
#include <cmath>
#include<iostream>
#include <fstream>
#include <vector>
#include <iomanip>
#include <sstream>
#include "EngineX.hpp"

using namespace std;

EngineX::EngineX(int hp) // Constructor with hp input
{
horsepower = hp;
}

EngineX::~EngineX()// Destructor
{}

string EngineX::name() // returns engine name
{
stringstream ss;
ss << horsepower;
string b(ss.str());
return ("EngineX " + b + "HP");
}

double torque(double rpm, double fuelRate) // returns engine torque
{
double lrpmx = 0;
double engineTorque = 0;
double torque = 0;
lrpmx = rpm / 1000;
torque = ((-130*lrpmx*lrpmx*lrpmx) + (-600*lrpmx*lrpmx) - (791 *
lrpmx) + 2);
engineTorque = fuelRate*torque;
return engineTorque;
}
thanks very much,

Zenon

Jul 19 '05 #2
Zenon wrote:
Folks,
I cannot figure out why I am getting an error: Error E2303 EngineX.hpp
19: Type name expected. Here is my code. Can you please help?

#ifndef EngineX__hpp
#define EngineX__hpp

#include<iostream>
#include <cstring>
#include <cmath>
#include <sstream>
#include <fstream>

class EngineX : public Engine


You didn't #inlude the header file that contains the definition for the
Engine class, so how is the compiler supposed to know about it?

Jul 19 '05 #3
Thanks, that makes sense. Do I just add an #include"Engine.cpp" right
after the #include "EngineX.hpp" statement? My engine file is
included below

#include<iostream>
#include <cstring>
#include <cmath>
#include <sstream>
#include <fstream>

class Engine
{
// define function prototypes
public:
// Engine(); // Default constructor
virtual ~Engine() = 0; // Destructor
virtual std::string name() = 0;// returns engine name
virtual double torque(double rpm, double fuelRate) = 0; // returns
engine torque

};

Engine::~Engine()// Destructor
{}
"Amit Gulati" <am********@cox.net> wrote in message news:<JGEsb.845$HD3.770@lakeread06>...
since EngineX is a subclass of Engine the compiler needs to know about
Engine??
You probably need to include the header file that has Engine class
declaration.

"Zenon" <ze****@comcast.net> wrote in message
news:b1*************************@posting.google.co m...
Folks,
I cannot figure out why I am getting an error: Error E2303 EngineX.hpp
19: Type name expected. Here is my code. Can you please help?

#ifndef EngineX__hpp
#define EngineX__hpp

#include<iostream>
#include <cstring>
#include <cmath>
#include <sstream>
#include <fstream>

class EngineX : public Engine
{
// Define data members
int horsepower;

// define function prototypes
public:

EngineX(int hp); // Constructor with hp input
~EngineX();// Destructor
std::string name(); // returns engine name
double torque(double rpm, double fuelRate);// returns engine torque
};
#endif

#include <cstring>
#include <cmath>
#include<iostream>
#include <fstream>
#include <vector>
#include <iomanip>
#include <sstream>
#include "EngineX.hpp"

using namespace std;

EngineX::EngineX(int hp) // Constructor with hp input
{
horsepower = hp;
}

EngineX::~EngineX()// Destructor
{}

string EngineX::name() // returns engine name
{
stringstream ss;
ss << horsepower;
string b(ss.str());
return ("EngineX " + b + "HP");
}

double torque(double rpm, double fuelRate) // returns engine torque
{
double lrpmx = 0;
double engineTorque = 0;
double torque = 0;
lrpmx = rpm / 1000;
torque = ((-130*lrpmx*lrpmx*lrpmx) + (-600*lrpmx*lrpmx) - (791 *
lrpmx) + 2);
engineTorque = fuelRate*torque;
return engineTorque;
}
thanks very much,

Zenon

Jul 19 '05 #4
Zenon wrote:
Thanks, that makes sense. Do I just add an #include"Engine.cpp" right
after the #include "EngineX.hpp" statement?
No. You #include "Engine.hpp" at the beginning of "EngineX.hpp".

My engine file is
included below

#include<iostream>
#include <cstring>
#include <cmath>
#include <sstream>
#include <fstream>
Do you really need anything from that in your header?
class Engine
{
// define function prototypes
public:
// Engine(); // Default constructor
virtual ~Engine() = 0; // Destructor
virtual std::string name() = 0;// returns engine name
virtual double torque(double rpm, double fuelRate) = 0; // returns
engine torque

};

Engine::~Engine()// Destructor
{}


Jul 19 '05 #5
My assumption (and I am obviously a newbie) was that the inheritence
of Engine by EngineX in the lclass definition
class EngineX : public Engine
was the mechanism for this. Now since I don't have a header file for
the base class Engine, how do I go about including it? Must I have a
header file? Thank you very much for your help.

Rolf Magnus <ra******@t-online.de> wrote in message news:<bo*************@news.t-online.com>...
Zenon wrote:
Folks,
I cannot figure out why I am getting an error: Error E2303 EngineX.hpp
19: Type name expected. Here is my code. Can you please help?

#ifndef EngineX__hpp
#define EngineX__hpp

#include<iostream>
#include <cstring>
#include <cmath>
#include <sstream>
#include <fstream>

class EngineX : public Engine


You didn't #inlude the header file that contains the definition for the
Engine class, so how is the compiler supposed to know about it?

Jul 19 '05 #6
Please don't top-post. Put your answers below the text you're referring
to. This is not jeopardy, where we get the answer before the
question ;-)

Zenon wrote:
You didn't #inlude the header file that contains the definition for
the Engine class, so how is the compiler supposed to know about it?
My assumption (and I am obviously a newbie) was that the inheritence
of Engine by EngineX in the lclass definition class EngineX : public
Engine was the mechanism for this.


If there is no Engine class, how could deriving EngineX from it work?
Now since I don't have a header file for the base class Engine, how do
I go about including it?
Where do you have that base class defined then?
Must I have a header file?


Well, your class Enigne must be fully known to the compiler at the point
where you define EngineX. Usually, this is done by #including a header
that contains the definition of the base class.

Jul 19 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Chris Asaipillai | last post by:
I have a problem executing the following Stored Procedure from code. The SP Text runs like this: ALTER PROCEDURE prc_InsertContractDirectStatus­_tmp @var_ContractID VARCHAR(50)
1
by: Andrew Edwards | last post by:
Could someone please tell me what I'm doing wrong? The compiler barks at me whenever I throw (bad_alloc). If I remove this the code compiles just fine. template < class DT, class KF > class...
3
by: Jeff Johnson | last post by:
I'm getting a Method Name Expected error when I try to compile. The error happens here: imgImage.Click += new ImageClickEventHandler(updateColours("X")); Can someone tell me what I'm doing...
1
by: David Lozzi | last post by:
Hello, My webservice is receiving the following error. It runs fine on my local development machine,but when moved to production it errors. I found one KB about this error but it was in regards...
7
by: Tony Tone | last post by:
I am having trouble resolving this issue: Server Error in '/test' Application. -------------------------------------------------------------------------------- Compilation Error Description:...
2
by: Poincarč_č_andato | last post by:
Hi all, I built a softwaare (4 finite elements) and now that i solved all maths troubles i'm trying to expand some informatic skills. I call EXE file from cmd (under XP) and i made bad...
1
by: jewel87 | last post by:
Hello, I am working on a program in C++ builder 6, which uses TDate and TDateTimePicker. I am getting the following error Product.h(58): E2303 Type name expected myGUI.cpp(39): E2316 'create'...
1
by: Alex Dransfield | last post by:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; namespace FindFactors { class Program {
1
by: Godlove Mathew | last post by:
Hi, I installed a Borland C++ in my laptop a 32-bit operating system with windows vista. I wrote i very simple program to display "Hello world" but it gives an error // my first program in C++...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.