Category : header-files

I have a class structure where I have some member variables declared like this: /* HEADER */ #ifndef SRC_HEADER_H #define SRC_HEADER_H class Service { private: typedef boost::multi_index_container<…> Checkpoints; Checkpoints checkpoints_ GUARDED_BY(mutex_); }; #endif Then I have the source file with the implementation: #include "src/header.h" /* some functions which use `checkpoints_` */ Is there a way ..

Read more

#ifndef LIGHT_H #define LIGHT_H static std::vector<glm::vec3> lightPos{ glm::vec3(0.0f, 0.0f, -6.0f), glm::vec3(-8.0f, 0.0f, -1.0f), glm::vec3(8.0f, 0.0f, -1.0f) }; #endif i want this variable in two different files, a friend said that extern is bad and ugly when using classes, but this variable is only being recognized in one file, game.h/game.cpp, but player.h/player. cpp doesn’t recognize it, ..

Read more

I am using a header file named OlcPixelGameEngine, and one more header file, but when I run the compile command, I get a big error. This is the command to compile the cpp program. g++ main.cpp -o main -luser32 -lgdi32 -lopengl32 -lgdiplus -lShlwapi -lstdc++fs -static -std=c++17 -lxinput9_1_0 -lole32 -loleaut32 -ldinput8 -ldxguid -ldwmapi and this is ..

Read more

While following the book C++ For Dummies, I have three files in my CodeBlocks project, main.cpp, Pen.h, and Pen.cpp. They look like this: main.cpp: #include <iostream> #include "Pen.h" //#include "Pen.cpp" using namespace std; int main() { Pen MyPen = Pen(); MyPen.test(); } Pen.h: #ifndef PEN_H_INCLUDED #define PEN_H_INCLUDED //#include "Pen.cpp" // Uncommenting this gives a different ..

Read more