Questions tagged [c++]

C++ is a general-purpose programming language. Initially, it was designed as an extension to C and has a similar syntax, but it is now a completely different language. Use this tag for questions about code (to be) compiled with a C++ compiler. Use a version-specific tag for questions related to a specific standard revision [C++11], [C++14], [C++17], [C++20], or [C++23], etc.

Filter by
Sorted by
Tagged with
0 votes
0 answers
16 views

Is there any way to get derived_class type from it's object (not reference to derived_class)

There is Log history of commands in any command language with changable state. Each Command is object that is added to Log when Run. Log is one of fields of State of language. Each Command needs to ...
0 votes
0 answers
16 views

Memory error using std::memcpy for matrix class

I'm writing a matrix class but I have a memory error in one of my member functions. I have a member function that inserts rows taking the starting row index and a matrix object as parameters. The ...
3 votes
0 answers
12 views

Get list of tags of remote repository without cloning using libgit2

Using this git command I can get all of the available tags of a remote repository without having to clone it: git ls-remote --tags https://github.com/blender/blender.git I want to replicate this ...
  • 2,801
1 vote
0 answers
11 views

Open and read from device using HID API

I'm writing a low level input system with the HID API. I've gotten to the point where I can enumerate all of the devices on a system, and open them with CreateFile. The problem I'm running into now is ...
0 votes
0 answers
12 views

Sobel filter doesn't filter horizontally

Basically my problem is that I apply Sobel filter to BMP image where 1 pixel is 1 bit. But it doesn't do anything to the image, while filtering horizontally. Sobel function: void sobelFilter(unsigned ...
0 votes
0 answers
12 views

C++ process snapshot returns [System process] and cant find a target exe in snapshot

I'm exploring writing/reading process memory and wrote a simple program that simulates health, as if it was a game. I wanted to rewrite the health int to something different through memory writing, ...
-1 votes
0 answers
9 views

How do I extract the first frame of a video stream as an image using avcpp?

I'm trying to extract the first frame of a video stream and save it as an image using the avcpp library (https://github.com/h4tr3d/avcpp). I have already written some code but I'm not sure how to ...
1 vote
0 answers
20 views

Using enum class with std::bitset and combining bitsets

I am trying to make write a code for i2c communication with a device (ADS1115). The communication uses different arrays of bits for commands and sending data back, in which most bits or group of bits ...
-4 votes
0 answers
30 views

How to specify the number of decimals to write a real number in float? C++17 [duplicate]

Make a program that reads three floating point values: A, B and C. Then, calculate and show: a) the area of the rectangled triangle that has base A and height C. b) the area of the radius's circle C. (...
  • 1
-1 votes
0 answers
26 views

Template Function in C++ [duplicate]

The code is so large and a bit to complicated so ill try to narrow it down. We have ClassX, defined like this template<typename T, bool B> class ClassX { // Function that takes in a different ...
  • 41
-3 votes
0 answers
18 views

How can I detect when the client close SSE (Server Side Request) in a cgi script (c++) executed via apache? [closed]

When the client close the SSE (close the browser) my program crash when calling std::cout. But I can't detect when the cout pipe is destroyed. When I test std::cout.good() it return me true even if ...
  • 112
1 vote
0 answers
21 views

How can I merge 2 bsp trees?

I am in work of implementing csg objects with bsp trees. For this purpose I need to merge 2 bsp trees and work with them, but I don't quite understand how to implement this merging. I know how to ...
0 votes
0 answers
8 views

why asn1_create_element exits with code 137 but asn1_print_structure don't

I'm trying to use asn1_create_element() from libtasn1.h but it exist with an error 137. However asn1_print_structure() that uses the same definitions and source works. asn1_print_structure(stdout, ...
-6 votes
0 answers
24 views

question about ability recharge rate and rate of fire in destiny 2

`hello i was wondering if anyone has the knowledge of coding some cheats in destiny 2 that gives you a quicker rate of fire and ability recharge rate in c++ ive tried many things but the codes never ...
  • 1
0 votes
0 answers
16 views

How to share memory between processes in Postgres FDW

I'm writing a postgres FDW extension for my custom data storage. I have a class that provides the API for the storage. initialization of the class is rather costly, and I also need to have access to ...
  • 352
1 vote
1 answer
31 views

C++ Template using an enum defined by a derived class

Basically here's what my "ideal" code would look like, if it were legal: template<typename ClassName> class Base{ ClassName::units_type units; public: Base(ClassName::...
  • 100
3 votes
1 answer
38 views

Why does MSVC refuse to compile `static_assert(std::size(array) < N)` when `array` declared thread local?

Attempting to compile some example.cpp containing the following: #include <array> void test() { thread_local int arr[10]; static_assert(std::size(arr) < 100); } MSVC 19.35.32215 ...
0 votes
0 answers
13 views

Why can I not configure the PLL clock properly?

I am currently trying to write a bootloader for an STM32F401 microcontroller using nothing but C++. In this project, I have removed all start files using -nostartfiles and have written all the startup ...
1 vote
1 answer
50 views

What type does eof return?

Both cppreference.com and cplusplus.com say it's int_type. But they don't explain (at least I couldn't find it, an neither could Bing Chat) what type it is. (I suppose it can be any signed integer ...
  • 737
4 votes
0 answers
42 views

Missing value_equal in std::unordered_map

I noticed that std::unordered_map does not provide a member class that allows equivalence comparison between two value_type, like value_compare in std::map. Is there a reason therefore the member ...
  • 99
-3 votes
0 answers
25 views

Automaton Word Validation Program with Bug in C++ [duplicate]

This C++ program reads in an automaton from a file in a specific format and prompts the user to input a word to validate against the automaton. The automaton is represented as a collection of states, ...
  • 1
3 votes
0 answers
29 views

c++ style "get or create" for map unique_ptr values

I want to make a tree where the nodes have a collection of unique_ptr child nodes. struct Node { map<int, unique_ptr<Node>> children; }; The typical way is calling find(), seeing if ...
2 votes
1 answer
31 views

shared_ptr std::dynamic_pointer_cast fails with "attempting to reference a deleted function" error

I have seen all the posts in StackOverflow regarding this similar error and still couldn't find what is causing issue in mine. I'm using std::dynamic_pointer_cast to cast a std::shared_ptr<Base> ...
  • 305
0 votes
0 answers
10 views

How to mirror one axis in raylib?

Change in coordinate system I am creating a game using the raylib library in c++. By default, raylib's coordinate system (top) origin is at the top-left corner of the screen with the positive x-...
  • 1
-4 votes
1 answer
39 views

How to subclass Pango::Renderer in C++

I'm trying to subclass the Pango::Renderer to draw text on an osg::Texture2D, but I cannot find a public constructor (except a copy-constructor) in its header file, neither another method to create a ...
  • 5,535
-4 votes
0 answers
26 views

Is there a way to download a file from Google Drive using Qt C++? [duplicate]

I have a file in Google Drive which I have made public. I want to download it using QT C++ and have written the following code. I have tried downloading other files (some other pdfs and rar) and it ...
0 votes
0 answers
8 views

Cannot compile Android API 25 app in Qt6.4.3

I've recently installer the latest version of QTCreator with Qt 6.4.3 and its Android component, I've configured the SDK and NDK as explained in the Qt website (see image) android kit config In the ...
  • 1
-2 votes
1 answer
49 views

Array merging (unsigned char[16] to unsigned long) template error after update toolset 142 ->143 (VS2022)

I have a set of errors appearing after the update from toolset 142 to 143 with a c++ (c++17) project in VS2022 (17.5.2). I am using those functions to do the type conversion: #ifndef ul #define ul ...
  • 6,085
1 vote
1 answer
15 views

Handshake is not working Http GET request with Boost.Asio

I'm trying to Boost.Asio to make a GET request to https://api.binance.com/api/v3/time, which it will show a result like this one: {"serverTime":1679236121308} To do this, I'm using Boost....
-3 votes
2 answers
59 views

How to use pointers with encapsulation (c++)

To practice using pointers in c++ (coming from experience of c#), I decided to try and write my own linked list class. However using classes and objects seems to do some wacky behaviour that I do not ...
-7 votes
1 answer
42 views

C++ generate random numbers for a given seed [closed]

I need to create a random number generator that generates n random numbers for a given seed s. k largest or smallest values generated are also known. ex1 : Seed (s): 123 No of random numbers (n):100 ...
  • 1
1 vote
4 answers
51 views

How to iterate through an enum summing the sizeof(s) of classes with the same name

I have an enum with variables names v1, v2..., vn, and each name has a corresponding class with the same name. I want to find, in compile time (even though I don't know if it's possible in run time ...
0 votes
0 answers
20 views

Displaying image with alpha channel in x11 window

I've created a window with a transparent background and can make it borderless but first, I want to display an image that is just uint32* in it. However, I got this error message below. When I try ...
0 votes
0 answers
21 views

Trying to use ifstream.read to get data into vector

Trying to read a part of a file into a vector structure. Specifically trying to read exif data just using standard library. This code compiles but the vector ("buffer") is empty. Been ...
1 vote
1 answer
44 views

Why does high resolution clock from chrono library output 0 and reasonable values in seemingly random order?

I have a function that I was using the chrono library to benchmark- at times the output would be zero for time passed and sometimes a more reasonable value- in my case about 973,300 nanoseconds. I ...
  • 11
1 vote
1 answer
49 views

C++ compiler support to detect returning a reference to a temporary object

There is a snipped code, that returns a reference to a temporary object: #include <iostream> #include <string> const std::string& forward(const std::string& s) { return s; } ...
-2 votes
1 answer
58 views

Why the default constructor is not initializing the variables?

When B b(0); is called I am expecting it to call the default constructor to initialize protected data member data_ but it is showing error. error: no matching function for call to ‘B::B(int)’ ...
0 votes
0 answers
25 views

RPi PicoW MacBookPro M2 - Cannot set up my own projection C/C++

I have just bought a pico w and I can run the example blink project just fine no issues what so ever. But when I want to create my own project, same code as the blink or others I find online, I cannot ...
-7 votes
0 answers
40 views

How to get path of folder, that opened in explorer in C++? [closed]

I want to make some DragAndDrop feature. To do this, I want to find out where the user pointer threw the file. I found how to get HWND from Pointer, but I do not know how to get the path of an open ...
0 votes
0 answers
18 views

Different headers in CTreeCtrl

I use CTreeCtrl in two applications, one my own and second the sample one. In both are different visual of headers - one is older typ from Win XP, second is modern typ from current versions of windows ...
-3 votes
0 answers
20 views

Deleting One Element from the Original Array Inside the Function without Returning It in C++ [duplicate]

I wrote the following code to remove the last element of array, but it didn't work: void Shrink(int* original_array, int size){ int* shrinked_array = new int [size-1]; for (int i=0; i<size-...
  • 1
0 votes
0 answers
24 views

Intel MKL (2023) find lowest eigenvalues (of complex hermitian sparse matrix) in C

I know this question is stupid. I want to find (only) the lowest M eigenvalues and eigenvectors of a complex hermitian sparse matrix. Intel MKL can clearly do this, but I am simply unable to find the ...
  • 1,117
2 votes
1 answer
40 views

Template argument deduce from scope resolution

i have my base and derived class as below class Disposable : public PolymorphicE { protected: virtual void Created() {} virtual void Disposing() {} public: template <typename ...
-1 votes
0 answers
18 views

why not all keys are handled outside the SFML event loop?

I am faced with the question of how to process keystrokes, in a loop or outside of a loop? And for this I need to read the clicks w a s d keys are not processed outside the loop on KeyPressed, but ...
0 votes
1 answer
22 views

Initial 3D vector member between constructor list and constructor body

I declare a 3d vector member in header file for Example Class: .h file: Class Example{ Example(); priveate: vector<vector<vector<int> > > v; }; I want to initialization ...
  • 149
0 votes
1 answer
20 views

Vulkan - Get multiple queues from the same family

I am currently following the vulkan tutorial series and stumbeled uppon this thing. When the author introduces a second queue (presentation) he creates VkDeviceQueueCreateInfo for every unique kind of ...
  • 335
-3 votes
0 answers
48 views

Internal pointer in C++ class lost outside o [closed]

I have small class contain char* member (simplfied it): class BytesEntity { public: // ... some other memeber... char* data; BytesEntity(); BytesEntity(int i); BytesEntity(...
0 votes
1 answer
30 views

Method overloading & Method Hiding in C++

Why does the compiler not throw error in main() for p->f4(); line. As per my understanding class B hides f4() and should throw error class A { public: void f1(){} virtual void ...
0 votes
0 answers
22 views

magick++ : image has wrong colors

Playing with Magick++ 6.9, I can't set the colors properly. When I open the document in Krita, the color shown is not the right one. The goal is to get the global pointer of the image and set the ...
0 votes
0 answers
16 views

Clang finds library, Mingw32 cannot find library to import

I have some C++ code to render some polygons to a window. It uses the SDL2 and the SDL2 gfx libraries. When I run make in the folder, it works. It doesn't work when I switch the compiler from clang to ...

1
2 3 4 5
15814