Good day, community!

Another stupid question.

There are two files in the project - Bow.h (header file) and Bow.cpp (it contains all the implementation from Bow.h). I enter the line #include "Bow.h" in Bow.cpp , thereby trying to link these two modules into one. But the compiler produces an error: In file included from Bow.cpp . Without this, swears that the Bow class is not declared. The same thing happens when I try to connect something to the main module.

Please direct me on the right path.

  • In file included from Bow.cpp and all? He writes something else? - PaulD
  • one
    @teanYCH, the question is not stupid, but ugly asked. You probably understand that the whole thing is in the contents of the files, or rather those lines that the compiler swears at. But we don’t see them ... - avp
  • @avp, thanks! This is what I call "send." I just contacted ++ for the first time, and have not yet mastered it. The compiler threw the message In file included from Bow.cpp. , and pointed to the line #include "Bow.h" and so I thought that the problem was in the connection. But after reading your comment, I realized what an idiot I was, and quickly found a mistake - after public I didn’t put a colon (a habit after Delphi) - teanYCH


1 answer 1

most likely forgot to enclose your .h file in a protective shell :)

 #ifndef __BOW_H_ #define __BOW_H_ #pragma once // здесь бывшее содержимое bow.h #endif 

You can of course without #pragma once . This will work on all compilers. On new ones, you can simply add #pragma once to the very beginning. __BOW_H_ is a constant that is usually chosen based on the file name to be unique.

  • No, there was an error in the code, but the compiler marked the string with the definition, and it confused me. now I know. And I still have to study the protective shells :) - teanYCH