Category "c++"

Why is my SDL_mixer playing my wav. file too fast?

From this Lazy Foo tutorial (https://lazyfoo.net/tutorials/SDL/21_sound_effects_and_music/index.php) I wrote the following lines of code: #include <SDL.h>

Integrating Crashpad with a Windows Qt application

We are trying to integrate Crashpad with our Qt application and have run into several errors. We built Crashpad and attempted to link it to our application usin

When to use std::launch::deferred?

Lines from Anthony William book: std::launch::deferred indicates that the function call is to be deferred until either wait() or get() is called on the fu

Performane issue for matlab-like reshape in OpenCV

I am translating a Matlab code to OpenCV. The Code Involves lots of reshaping of large Matrices. As the matlab reshape differs from OpenCV you can't just use Op

Significant digits with IEEE 754 float

The Wiki Double-precision floating-point format says: This gives 15–17 significant decimal digits precision. If a decimal string with at most 15 signific

Direct way of computing clockwise angle between 2 vectors

I want to find out the clockwise angle between 2 vectors(2D, 3D). The clasic way with the dot product gives me the inner angle(0-180 degrees) and I need to us

What's the difference between constexpr and const?

What's the difference between constexpr and const? When can I use only one of them? When can I use both and how should I choose one?

Why does SDL_RenderPresent disable my quit event?

I wrote this program that outputs the coordinate of my current mouse position: #include <sdl.h> #include <iostream> int main (int argc, char** argv

Why won't this C++ program compile and run? [duplicate]

I tried to run a basic C++ file in the terminal: #include <iostream> using namespace std; int main() { cont << "This is my f

Accessing private fields and function from main

I've programmed only in Java in my career and started using C++ since 10 days, so this question may seem strange to many of you. I have defined the structure of

Coverity: command line build script for basic c++ code

I am working on a requirement to do instrumented build for c++ code on coverity(static code analysis tool, version 7.5.1) build server via command line. Need to

Rotate a 3D- Point around another one

I have a function in my program which rotates a point (x_p, y_p, z_p) around another point (x_m, y_m, z_m) by the angles w_nx and w_ny. The new coordinates are

const vs constexpr on variables

Is there a difference between the following definitions? const double PI = 3.141592653589793; constexpr double PI = 3.141592653589793; If not, which styl

Number of trailing zeroes

I've written a function trailing_zeroes(int n) that returns the number of the trailing zeroes in the binary representation of a number. Example: 4 in binary is

Destructors but for functions

New to c++ and possibly a really stupid question, but is there something like a destructor but for functions? I making a sort of game and as you can see that th

CalcOpticalFlowLK camera motion c++

this time i would know how can i calculate for each frame the camera motion in term of x and y pixel coordinates, i've googled and i've found that CalcOpticalFl

Visual Studio 2022 cannot compile C++ and ASM

I wrote a C++ project with some assembly code files in it. The project files include a C++ file with a main function, and a test.asm file. I configured the proj

How to go to next line after every row in a 2D array?

So I need to come up with something like this: It's a layout of seats on an airplane. 1 A B C D 2 A B C D 3 A B C D 4 A B C D 5 A B C D

error: invalid use of non-static data member

class Stack { private: int tos; const int max = 10; int a[max]; public: void push(int adddata); void pop(); void pr

error: invalid use of non-static data member

class Stack { private: int tos; const int max = 10; int a[max]; public: void push(int adddata); void pop(); void pr