Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compilation error: `Class' does not name a type

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?

like image 532
moto Avatar asked Feb 26 '26 19:02

moto


1 Answers

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

#include <iostream>
#include <cstdlib>

class Simulator {
    // Stuff here
}
like image 128
Justin Niessner Avatar answered Mar 01 '26 10:03

Justin Niessner



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!