Reputation: 21
I have a pretty simple class called simulator in simulator.h
#include <iostream.h>
#include <stdlib.h>
Class Simulator {
private:
short int startFloor;
short int destFloor;
public:
void setFloors();
void getFloors(short int &, short int &);
};
Now when I compile it, I get this error:
simulator.h:4: error: `Class' does not name a type
What have I got wrong here?
Upvotes: 2
Views: 3344
Reputation: 245429
You need to make Class
lowercase (and should probably stop using the deprecated iostream.h
header):
#include <iostream>
#include <cstdlib>
class Simulator {
// Stuff here
}
Upvotes: 5
Reputation: 17321
When you write
Class Simulator {
the compiler thinks 'Class' is a type like int, float or a user-defined class, struct or typedef.
The keyword used to define classes in c++ (as other answers also mention) is 'class'. Note also, the new header file names are iostream (since its a standard c++ header), and cstdlib (since its actually a c header).
Hence it should be
#include <iostream>
#include <cstdlib>
class Simulator {
private:
short int startFloor;
short int destFloor;
public:
void setFloors();
void getFloors(short int &, short int &);
};
Upvotes: 1