Category "c++"

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

C++ STL vector for existing data

Can I create an std::vector using my pre-existing data instead of it allocating new memory and copying the data? To be clearer, if I have a memory area (either

initialize a vector to zeros C++/C++11

I know in C++11 they added the feature to initialize a variable to zero as such double number = {}; // number = 0 int data{}; // data = 0 Is there a simila

Understanding Hierarchy, from findContours opencv

I am trying to understand Hierarchy and findContours, from opencv c++, but am finding it difficult. I did go through this question here, but I still am not abl

Confusion about declaration and definition of static const data memebers

Scott Meyers writes in Effective Modern C++ (Item 30 page 210) that there's no need to define integral static const data members in classes; declarations alone

JPEG Compression using OpenCV

I'm trying to perform a basic JPEG Compression (DCT + quantization + IDCT) using OpenCV not using entropy-encoding/Huffman-coding. The problem is that after I d

cuda 10.2 in Qt 5.14 ubuntu 18.04

I am planning to start cuda programming in Qt framework. I would like to start with a simple example. system information : OS : ubuintu 18.04 LTS Qt version : 5

C++ concatenate two int arrays into one larger array

Is there a way to take two int arrays in C++ int * arr1; int * arr2; //pretend that in the lines below, we fill these two arrays with different //int values