473,385 Members | 1,927 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,385 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 19133
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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,...
0
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...

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.