Category : c++

The problem is quite strange. Basically my project works well, builds and there are no errors. All .h files are included and all was fine till now. I just cant open .h in Visual Studio. It gives no errors and just does not open files. Header files are situated in correct folders. I even reseted ..

Read more

I am trying to add a sphere to my openGl project, and enable lighting for this object only, and finally disable the lighting. But the sphere is not showing up! here is the code for the sphere: void ball() { GLfloat black[] = { 0.0, 0.0, 0.0, 1.0 }; GLfloat white[] = { 1.0, 1.0, ..

Read more

I am trying to create a vector of maps. Each map has a different comparator. Here is what I have tried:- #include<iostream> #include<map> #include<vector> template <class T> struct head { virtual bool operator() (const T& x, const T& y) const = 0; }; template <class T> struct greater: head<T> { bool operator() (const T& x, ..

Read more

Description: I have multiple threads (4-32). These threads can all access an array: int resources[1024]. Resources array contains different values (0-1023). There can only be one instance of a single resource(int). Each thread requires different number of resources, which are at some point returned back to the array. Threads can ask for resources more than ..

Read more

I have this CMakeLists.txt set(Boost_USE_STATIC_LIBS ON) find_package(Boost REQUIRED COMPONENTS json) include_directories(${BOOST_INCLUDE_DIRS}) target_link_libraries(<Target> PRIVATE Boost::json) But I get cmake warnings [cmake] CMake Warning at C:/Program Files/CMake/share/cmake3.20/Modules/FindBoost.cmake:2185 (message): [cmake] No header defined for json; skipping header check (note: header-only [cmake] libraries have no designated component) The project can configure and build tho. But the compile_command.json I found ..

Read more

Raed wants to buy a house, but he doesn’t have enough money. He decided to take a loan from a bank. The loan process according to the bank’s rules. Assume the loan is repaid in equal monthly payments and interest is compounded monthly. The amount (principal p) of the loan, and the number of years ..

Read more

I’m reading an article and I came across this program: #include <iostream> #include <vector> using namespace std; int main() { vector<int> a(2, 10); } I know that if it’s a(2) then the vector has size of 2 elements but what is the meaning of a(2, 10)? Also can I change the vector<int> a(2, 10) into ..

Read more