Category "c++"

Ternary operator implicit cast to base class

Consider this piece of code: struct Base { int x; }; struct Bar : Base { int y; }; struct Foo : Base { int z; }; Bar* bar = new Bar; Foo* foo =

Why does new int() work like an array in C++?

As far as I understand int* p = new int(); Is something like creating an int with a constructor. If so why does the following code work like an array? int* p =

How can I make sure `iostream` is available to the linker?

I have the following C++ code in a file called helloworld.cpp: #include<iostream> int main() { std::cout << "Hello, World!\n"; } I would like

SNMP client error when authentication with MD5 algorithm

The Ubuntu SNMP client worked correctly with SHA authentication, but failed with MD5. Error: Authentication failure (incorrect password, community or key) snmpd

Create an identifier at compile time that has the line number as part of it [duplicate]

I want a C++ preprocessor macro that creates a new identifier with the line number as part of it. This is for using the identifier as a throwa

Need Help Understanding OpenMP Matrix Multiplication C++ code

Here is my Matrix Multiplication C++ OpenMP code that I have written. I am trying to use OpenMP to optimize the program. The sequential code speed was 7 seconds

Using bullet physics car and heightfield, car get stuck how can I fix?

I've been working on implementing a car in my game using bullet physics. The physics of the car uses btRaycastVehicle and the code is mostly based on the ForkLi

How to read a .txt file from terminal, and then extract contents from file?

I am wanting to use C++ to extract the contents of a .txt file (that will be pointed to from the terminal) that is to be parsed, but I am not sure how to go abo

How to use select to properly detect whether I am building C++ code in Windows or Linux?

I am writing a sample C++ project that uses Bazel to serve as an example idiom for other collaborators to follow. Here is the repository: https://github.com/th

normalize histogram in c++ - function normalize in openCV

I need to normalize the histogram of an image f which mean to applicated an transformation of histogram from image in order to extend the range of value of f to

Use macro definitions (e.g. M_PI) in math.h as float not double

I noticed that all the mathematical constants are declared as double, which leads to conversion problems on some platforms where no double precision units exist

Struggling with libssh on Windows

The problem I'm trying to build a project in Visual Studio 2015 on Win10 that makes use of libssh, but I'm having no luck getting it to work. I feel like I'm l

Windows Open Dialog Box hangs forever with Address Sanitizer enabled

When Address Sanitizer is enabled, the Open Dialog Box cannot be shown. It hangs forever. Thank you. It hangs when running hr = pFileOpen->Show(N

IDE Font spacing problems

A couple months ago, the font I was using in the NetBeans IDE suddenly had huge spaces between each letter, making it almost unreadable. (I was using the Papyru

Can I launch a cooperative kernel without passing an array of pointers?

The CUDA runtime API allows us to launch kernels using the variable-number-of-arguments triple-chevron syntax: my_kernel<<<grid_dims, block_dims, shar

Libwesockets.h: Issue with lws_write: C++ string to C conversion and send

I'm using g++. Code: std::string str = "{\"action\":3,\"data\":{\"account\":\"somehashgoeshear\",\"someint\":0,\"id\":1,\"moreint\":0,\"name\":\"demo\

Measuring bandwidth on a ccNUMA system

I'm attempting to benchmark the memory bandwidth on a ccNUMA system with 2x Intel(R) Xeon(R) Platinum 8168: 24 cores @ 2.70 GHz, L1 cache 32 kB, L2 cache 1 MB a

cannot convert int (*(int))(int) to int (*(int))(int)

i'm trying to learn about function that returning a pointer to a function, after i tried to compile the code, it gives me this kind of error: cannot convert

Unable to use std::apply on user-defined types

While implementing a compressed_tuple class for some project I'm working on, I ran into the following issue: I can't seem to pass instances of this type to std:

OpenMP-behavior: Using ICC and GCC gives significantly different run times

For a small benchmark of OpenMP on an i7-6700K I wrote the following code: #include <iostream> #include <omp.h> #include <vector> #include <