Category "c++"

I try to use placement new, but always complies error

#include <iostream> #include <new> const int BUF = 512; const int N = 5; char buffer[BUF]; int main(){ using n

Range-v3 operator overloading to write shorter code

For my matrix class I want to do some sort of operator overloading (probably using expression templates) on range-v3 views for + - / * % . For example if I want

How to add rows with the same specifications as the ones in a tableWidget after a table is already created?

In my app I enter a vlaue and said value sets the number of rows to the table. Within the function I will post here I do all the stuff related to setting up the

Why don't compilers optimize trivial wrapper function pointers?

Consider the following code snippet #include <vector> #include <cstdlib> void __attribute__ ((noinline)) calculate1(double& a, int x) { a += x

Extract the century of a date from a string

My task is to output the current century of a given date. The date can be represented as a string; for example, 19.03.2022. How can I retrieve the year and cent

Unable to refer to typedef struct definitions done in Win32 Header files (.h files in External dependencies) from WinRT C++ Library

Unable to refer to typedef struct definitions done in Win32 Header files (.h files in External dependencies) when consumed from WinRT C++ Library #include <m

Random access of a linked list element

In an article about linked list, it is said that accessing a random element is not allowed and to access a certain node we need to traverse it from the head nod

Why glBufferSubData is slow?

When trying to access GL_ARRAY_BUFFER using glBufferSubData to 128 byte buffer size, accessing takes at worst 200 microseconds. Instead when allocating whole bu

Neatly linking dependency tuple references specified by variadic class args

Given the following class structure in which we possess a number of different classes C#, each with unique data that is passed into a number of ledgers L<C#&

How to add more than one header(HDRs) and object in a makefile?

HDRS = EventLoop.h Data.h OBJS = EventLoop.o Data.o dict_$(PROGRAM).o This is from my makefile, I want to add another Data.h and Data.o in it , kindly help! Tri

Ambiguous overload error when using conversion function

I am trying to understand overloading resolution in C++ through the books listed here. One such example that i wrote to clear my concepts whose output i am unab

Rewrite a C++ vector to java vector

My task is to migrate a code from C++ to Java. In the C++ there is a vector called vector1 with the following code: vector1[0].insert(vector1[0].begin(), to_str

Write a macro function to change the case of a string?

// I tried this code #include<iostream> using namespace std; // Function to convert characters // of a string to opposite case #define case_change(s

Why is Signed Overflow due to computation still Undefined Behavior in C++20

I came to know through this answer that: Signed overflow due to computation is still undefined behavior in C++20 while Signed overflow due to conversion is wel

How do you declare a stack of type struct? in c++

In the code below, how do you properly declare a stack of type struct and push strings onto the stack so that they are saved in the struct? How do you specify w

Copying assets directory from source to build directory in CMake

I am trying to write a game for practice in C++. I am using CMake for this, and my project gets built in a separate build directory automatically by my IDE. How

Hikvision IP PTZ camera control with LabVIEW

I want to control hikvision camera with LabVIEW. By using the "NET_DVR_RealPlay_V30" function of the "HCNETSDK.dll" file compiled with C/C++ with "Call Library

Problem with deprecated conversion from cv::mat to IplImage

I know there were already questions like this in the past but all the answers seem not to work anymore since some functions are deprecated so I hope you can hel

How to watch instance method operator() result in VSCode C++?

My code is as follows: class Foo{ public: int operator()(int i) { return 1; } int operator++(int i) { return 1; } }

Need help to solve error in drawing histogram in root

this is my code I am checked it many times but it gives me an error when I run it. TFile *f=new TFile("hist.root"); TH1F *h = (TH1F*)f->Get("Phi_mu"