views:

61

answers:

6

Hi, 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?

+1  A: 

I think it's lowercase class.

Vasileios Lourdas
+1  A: 

should be lowercase "class" instead of "Class" ;)

arnaud
+5  A: 

You need to make Class lowercase (and should probably stop using the deprecated iostream.h header):

#include <iostream>
#include <cstdlib>

class Simulator {
    // Stuff here
}
Justin Niessner
Might as well use `<cstdlib>` too.
GMan
@Justin : `<iostream.h>` isn't deprecated. It was never a part of the Standard.
Prasoon Saurav
@Prasoon - Which is why I would (and others I know) consider it deprecated (something doesn't have to be standard to be deprecated). There is a standards compliant version that should be used instead.
Justin Niessner
@Justin : Even I had the same doubt once. Read Alf Steinbach's reply [here](http://groups.google.com/group/comp.lang.c++/browse_thread/thread/e4d5a24bd0812184/98b5f9b3266878e7#98b5f9b3266878e7)
Prasoon Saurav
+1  A: 

It must be lower case class.

It must be

#include <iostream>
ArunSaha
A: 

Make the 'C' a 'c' in the word Class. Has to be lower case.

dgnorton
That was right. Of all the syntax errors, I made one with a typo :(
moto
+1  A: 

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 &);  

}; 
highBandWidth