This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

C++ definitioins in header file

I am trying to use a class in Keil for Arm, but when I define my class in the Header the compiler complains that "class" is not known.

If I move the class definition to the *.cpp file, then the compiler seems to be happy. However, now I have no way to use this class in another module because the class definition is not in the header.

What is it that I need to do to resolve this issue?

Parents
  • when I define my class in the Header the compiler complains that "class" is not known.

    And how exactly did you come across that error? You didn't, by any chance, try to compile the *.h file itself, did you? If so, how was uVision supposed to guess that this was a C++ header file, rather than a plain C one?

    C++ and C are different languages. The compiler has to be informed which of these you want to use. If you don't, the default is typically C, and that doesn't know about the "class" keyword.

Reply
  • when I define my class in the Header the compiler complains that "class" is not known.

    And how exactly did you come across that error? You didn't, by any chance, try to compile the *.h file itself, did you? If so, how was uVision supposed to guess that this was a C++ header file, rather than a plain C one?

    C++ and C are different languages. The compiler has to be informed which of these you want to use. If you don't, the default is typically C, and that doesn't know about the "class" keyword.

Children