Questions tagged [c++]
C++ is a general-purpose programming language. Use this tag for questions about/utilizing C++. Do not also tag questions with [c] unless you have a good reason. C and C++ are different languages. Use a versioned tag such as [c++11], [c++20] etc. for questions specific to a standard revision.
809,587
questions
0
votes
0
answers
6
views
Is it possible to define a C++ function where one parameter is passed via the EAX register?
An old game doesn't work on my PC and I want to fix it.
A function of the game might cause the problem.
So I decided to hook this function with Detours.
The following code is generated by IDA.
...
1
vote
1
answer
32
views
pushing a unique_ptr into a vector of variant unique_ptr
I am playing around with c++ and faced this question
if I have a variant that looks like this:
using Fruit = variant<Apple, Tomato>
and a vector of unique_ptr of variant:
vector<unique_ptr<...
-2
votes
1
answer
42
views
is there any UB in reinterpreting a standard layout struct as an unsigned char*
I wanted to see if it is safe to reinterpret_cast a Colour struct into an unsigned char* to pass around for APIs
struct Colour {
unsigned char r,g,b,a;
};
static_assert(sizeof(Colour) == sizeof(...
1
vote
0
answers
13
views
how to extend std::formatter without sometimes introducing conflicts (can concepts when re-evaluated later in program return diff answer)
I am familiar with how to specialize std::formatter; it's relatively easy and clear with explicit specialization.
But with partial specialization - its a challenge - due to shifting nature of various ...
-2
votes
0
answers
24
views
Memory Leaks found in boost logger C++ [duplicate]
I have a client/server app, I'm using Dr.Memory to debug and find mem leaks. The issue is that there are too many from the logger i've created for my application. Find the minimum reproducible example ...
-4
votes
0
answers
54
views
C++ For Loop is not working correctly and cant find the bug [closed]
i have been working on a c++ program that calculates the arithmetic, geometric and harmonic means.
the first instance of the calculation gives the correct figures for the arithmetic, geometric and ...
1
vote
1
answer
28
views
Setup libstdc++ for a given gcc version
New to Linux here.
Already had gcc 11 and 12 on my ubuntu but compiled gcc-14 using following command:
./configure -v --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --...
0
votes
0
answers
12
views
How do I set up collision criteria in SMFL between CircleShape objects using object attributes?
I am implementing the simple game "Connect Four" and want to detect the presence of a stationary disc immediately below a falling disc as criteria for the falling disc to stop.
I am using ...
-1
votes
0
answers
19
views
Trouble setting up OpenGL on Windows (in VS Code)
I am following the tutorial text to setup OpenGL on Windows 11.
This is the main script(HelloWorld.cpp):
#include <GLFW/glfw3.h>
int main(void)
{
GLFWwindow* window;
/* Initialize the ...
3
votes
1
answer
66
views
Explicit object member function with void parameter
According to cppreference since C++23
For a non-static non-virtual member function not declared with cv-qualifier or ref-qualifier, its first parameter, if not being a function parameter pack, can be ...
-7
votes
0
answers
23
views
secp256k1 library building for C++ [closed]
The name speaks for itself. How do I compile(use) secp256k1 for use in a personal project. I've never compiled libraries before and was looking for some guidance. I'm using Windows 11 ...
1
vote
1
answer
45
views
Having issues calculating APSP for matrix size n >= 4
I'm having issues finding the problem with the following implementation of Floyd-Warshall APSP Algorithm.
Currently working on a vjudge exercise and I'm having issues figuring out what's the problem ...
0
votes
0
answers
52
views
In C++, when is it better to use a class with a state and an "execute" method, vs just a function? [closed]
My question is about code design in general, but consider the specific context of a numerical integration tool.
Option 1: a class with a state, setters, accessors, and an execute method.
class ...
0
votes
2
answers
82
views
Difference between a mutable and immutable string
I just started studying C++, but there is a thing that I don't fully understand: when you initialize a std::string variable with a string literal, like this:
std::string str = "some string";
...
-1
votes
0
answers
30
views
Compiling X11 on ubuntu results with undefined reference errors
i have problem with compiling my project on Ubuntu.
This is my project: https://github.com/23vbq/tv-managing-system/
It contains directory endpoint with Makefile.
I was developing it on Arch and ...