Category : static

I am currently getting familiar with restbed for a project but ran into a problem right at the start. I admit that this might be something very trivial but still a problem for me at the time. Restbed service requires a const callback function void set_method_handler( const std::string& method, const std::function< void ( const std::shared_ptr< ..

Read more

there are few question like this but not exactly same so please care to read whole question before cast it as duplicate one 1. objects created using new keyword (dynamic objects). we explicitly use delete keyword to de-allocate there memory. so when program encounter delete keyword it get sense that object is going to end ..

Read more

I’m new to static variables in C++ and I’m trying to create some global variables that avoid the Static Initalization Order Fiasco with singletons. However I’m having trouble understanding how to use the singleton design pattern in this example. I’m defining two global A pointers global1 and global2 that require a reference to one another. ..

Read more

I’m new to static variables in C++ and I’m trying to create some global variables that avoid the Static Initalization Order Fiasco with singletons. However I’m having trouble understanding how to use the singleton design pattern in this example. I’m defining two global A pointers global1 and global2 that require a reference to one another. ..

Read more

I have a static std::unique_ptr map that I declared in a getter in X.cpp and use to access the map in both X.cpp and X.h. e.g. std::unique_ptr<std::map<…>>& getMap() { static std::unique_ptr<std::map<…>> xMap; return xMap; } However, it seems I’m getting a read access violation in X.h saying that the pointer is null. Would the best ..

Read more

I have a actor class ANodeBase. Each node must have a unique id. To realize that, i create static variable id_counter. Code: //ANodeBase.h static int id_counter; //ANodeBase.cpp #include "NodeBase.h" int ANodeBase::id_counter = 0; ANodeBase::ANodeBase() { PrimaryActorTick.bCanEverTick = false; id = id_counter; id_counter++;//the only change to a variable in the project } Problem is that id_counter ..

Read more

Why do I get this error en C++? Files: radiacaoapp.cpp #include <iostream> #include "include/radsurf.h" using namespace std; int main(){ radsurf a(0.1,2); return 0; } radsurf.h #ifndef RADSURF_H #define RADSURF_H class radsurf{ public: float e; float A; int num; static int total = 0; radsurf(float aux1,float aux2){ e=aux1; A=aux2; radsurf::total++; num=radsurf::total; } }; #endif // RADSURF_H ..

Read more