473,854 Members | 1,508 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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<iostre am>
#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<iostre am>
#include <fstream>
#include <vector>
#include <iomanip>
#include <sstream>
#include "EngineX.hp p"

using namespace std;

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

EngineX::~Engin eX()// 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 19287
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.goog le.com...
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<iostre am>
#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<iostre am>
#include <fstream>
#include <vector>
#include <iomanip>
#include <sstream>
#include "EngineX.hp p"

using namespace std;

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

EngineX::~Engin eX()// 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<iostre am>
#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.hp p" statement? My engine file is
included below

#include<iostre am>
#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@lakere ad06>...
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.goog le.com...
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<iostre am>
#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<iostre am>
#include <fstream>
#include <vector>
#include <iomanip>
#include <sstream>
#include "EngineX.hp p"

using namespace std;

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

EngineX::~Engin eX()// 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.hp p" statement?
No. You #include "Engine.hpp " at the beginning of "EngineX.hp p".

My engine file is
included below

#include<iostre am>
#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<iostre am>
#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
7583
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
5831
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 BSTree; template < class DT, class KF > class BSTreeNode { private:
3
8969
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 wrong? Thanks,
1
6154
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 to .Net 1.0, this server is 1.1. Thanks! Configuration Error Description: An error occurred during the processing of a configuration file
7
12895
by: Tony Tone | last post by:
I am having trouble resolving this issue: Server Error in '/test' Application. -------------------------------------------------------------------------------- Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
2
2093
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 discoveries like that string for argvector must be not more than 127 chars long... I solved all except 1 thing: I'm using Borland TC with compact size for stack dimension (with bigger sizes EXES raise windows ferocity) and I mallocated dynamic vectors in...
1
2044
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' is not a member of 'Product' for the following function: void create(TEdit *EnterProductID, TEdit *EnterProductName,
1
13418
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
13308
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++ #include <iostream> using namespace std; int main ()
0
9901
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
11025
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10682
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10758
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10371
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7915
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5743
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4562
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4159
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.