Category "c++"

How to create a time point from milliseconds since Unix epoch?

To create a time point for the current time, you can use: std::chrono::system_clock::now(). I cannot figure out, however, how to create a time point given milli

How does #include <bits/stdc++.h> work in C++? [duplicate]

I have read from a codeforces blog that if we add #include <bits/stdc++.h> in a C++ program then there is no need to include any other h

Does cross-platform C++ require building separately on every single platform?

My question actually has two variants, but for some context, I have a C++ *.DLL that I use with Unity using P/Invoke. It's built on Windows 10 with MSBuild (pla

Which type of #include ("" or <>) when writing a library in C/C++

I am writing a library in C++. The library has multiple headers and cpp files and needs to be cross platform (Windows Visual Studio and Linux gcc). When built t

Algorithm to convert std::stack to std::string in C++ STL

In below C++ program I'm deleting a previous character considering '#' as a backspace character. I have used stack to build the string. Is there any C++ STL alg

How to properly return in a switch case? [closed]

Let suppose the following example: int main() { int value=1; switch( value ) { case 1: { return 0;

‘is_trivially_copyable’ is not a member of ‘std’

My gcc version is 4.8.3 20140624. I can use is_pod, is_trivial, is_standard_layout, but fail when trying is_trivially_copyable, is_constructible and is_default_

OpenGL black screen(GL_PERSPECTIVE, GL_MODELVIEW problem)

I'm trying to move the perspective view, so I can see that the sun, earth, and moon is moving around on a screen. I'm keep searching and trying to fix this but

How static function is accessing private member function(constructor) of a class

I came across code like the below, which is basically an example of a singleton class in which we make the class constructor private and provide one static publ

Missing Dll in dependency walker

I am having a dll and which I am opening into the dependency walker with platform visual studio 2003 and OS is 2000. and my that dll find all dependency. But w

Program in c++ tell if a number is integer or float

I used function overload to check if an input number is integer or float. However I get this following error: error: call of overloaded 'retNr(double)' is ambig

Import std lib as modules with clang

I am experimenting with modules in clang, and would like to include the standard lib as modules instead of as includes. Currently I do this #include <iostrea

error: ‘selectROI’ is not a member of ‘cv’

I use Ubuntu 18.04 and opencv3.4.0(with 3.3.1contrib), when i try to compile my project, these errors occured: /home/sunyq/SiamMaskCpp/demo.cpp:98:24: error: &l

Problem with std::index_sequence_for as default argument?

The following C++20 program: #include <utility> #include <cstddef> template<typename... Args> class C { template<size_t... I> s

Why the boost msm calls the guard twice?

I'm implementing a state machine as the following diagram state machine diagram I trigger "event1" and "event2" to the state machine, when "event1" triggered,

How is an 'undefined symbol' error possible if shared dependencies provide that symbol?

I'm trying to compile GTK 3.24.33 from source. At some point in the build process I got the following error Cannot load module /home/felix/apps/src/libraries/gt

How to store a *signed* 24 bit int into another variable?

I need to encode a 24 bit integer into the end of 32 bit int. (the first byte contains other data, the other three are empty for use by the 24 bit int) I alr

Run button is disabled in Qt Creator

This happens even on a freshly created, empty project. The Run (and also Debug) buttons are disabled for the Qt5 configuration (they're enabled for the Qt4 con

How to initialize `std::function` with a member-function?

I am trying to learn std::function and here's my code: #include <iostream> #include <functional> struct Foo { void print_add(int i){ st

Socket Programming, Casting sockaddr_in to sockaddr. Why?

Here is a sample socket programming snippet from the client side. My question revolves around the type-casting that casted sockaddr_in into sockaddr. My questio