0

I am attempting to create a simple class header file. I have done the following so far:

#ifndef RECORD_H
#define RECORD_H

class Records{
    int idNumber;
    int serialNumber;

public:
    Records();
};

#endif

However, I am getting the following error:

[Error] unknown type name 'class'

What am I doing wrong?

Amen
  • 1,524
  • 5
  • 22
  • 41

2 Answers2

0

You're probably compiling it as C rather than C++. That is why you are getting that error..

Make sure your source file has a .cpp extension.

lakshmen
  • 28,346
  • 66
  • 178
  • 276
0

As lakesh said, you may to compiling as C rather than C++. Most compiler use the file extension to determine how to compile the file (use .cpp instead of .c)

If that's not it, then the problem would probably be in the a different file loaaded before this.

    // Record.cpp
    #include "badfile.h"   // error in here
    #include "record.h"    // error showing up here.
James Curran
  • 101,701
  • 37
  • 181
  • 258