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.
398
questions
0
votes
0
answers
13
views
Is there a way or solution to cancel the wait for other hpx::future get function, when using HPX?
There are many parallel tasks in my projects. I use hpx::future(usually declared in std::vectorhpx::futrue) to get task result for every one. Each task takes a different amount of time. When a task is ...
-7
votes
1
answer
72
views
c++ giving error: invalid conversion from 'int*' to 'int' [duplicate]
I tried running a program that made an array, but when I tried to run the array, it returned the error stated in the title.
This was my code
#include <iostream>
using namespace std;
int main(){
...
2
votes
0
answers
41
views
Is the initialization of an object a modification to a memory location when considering conflict actions?
struct A{int a; A():a(1){}}
std::atomic<A*> x;
// thread 1:
A* ptr = new A(); // #1
x.store(ptr,memory_order::relaxed);
//thread 2:
auto ptr = x.load(memory_order::relaxed);
int b = ptr-&...
0
votes
2
answers
62
views
Is a static_cast from a base to derived class well-defined when both classes have the same layout?
I would like to create C++ bindings for a C API. Would the following be undefined behavior?
typedef struct ABC_Foo { int x_; } ABC_Foo;
namespace abc {
class Foo : public ABC_Foo {
public:
int x() ...
-1
votes
0
answers
34
views
Undefined reference to _imp__glClear@4? [closed]
I have been trying to set up a graphics environment using GLFW following this tutorial on OpenGL.
I have been having a great deal of trouble installing the GLFW library using CLion and by extension ...
1
vote
0
answers
80
views
Difference in Memory Usage Between malloc and new in C++
I'm observing a difference in the total memory allocation when using malloc versus new in a simple C++ program, as reported by Valgrind. Below are the two versions of my program and the corresponding ...
1
vote
0
answers
28
views
Is there a Qt event for when a QLayout has finished redoing geometry?
I have a custom class which extends QWidget and installs a vertical box layout on itself, as well as child widgets which are added to said layout. In this sense, it is a composite widget.
I have a ...
0
votes
1
answer
25
views
Linker Error with MariaDB Connector/C++ When Using CMake
I'm encountering a linker error while trying to build a project using the MariaDB Connector/C++ 1.1.4 on Windows with CMake. I installed the MariaDB Connector/C++ from the MariaDB download page and ...
-7
votes
1
answer
81
views
Using sqrt function within a while loop, don't understand it
I'm currently going through "C++ Without Fear, Third Edition". I'm a little confused with this block of code, I understand how the if statement is used to find out if n is divisible by i. I ...
1
vote
0
answers
40
views
TOMS 748 - "the bounds given must bracket a single root"?
I have a cubic equation f(x)=0 which I need to solve numerically to within some tolerance.
I already have values a and b such that f(a) and f(b) have opposite signs; i.e. the interval [a,b] is known ...
-4
votes
0
answers
26
views
Exporting program instructions into a file that an application can read and execute [closed]
I am writing a web application (let's call it App 1) that allows users to write simple instructions for a separate app (native, lets call it App 2) in a visual manner. Something similar to Google's ...
-1
votes
0
answers
23
views
Is it a good practice for wrapper function/adapter function to be overload of the original function? [closed]
I believe the title describes my question well enough, but still I will an example:
std::string GraphFunction(std::function<std::vector<float>(float)>function, FunctionGraphingParameters ...
-3
votes
0
answers
37
views
Is there a reliable way to block the RobloxPlayerBeta.exe? [closed]
I've noticed my younger sibling is always glued to my computer when playing Roblox and it has become somewhat of an issue in my whole family. I decided to find a solution by blocking the ...
1
vote
1
answer
50
views
C++ overload resolution problem: How to make vector fill constructor overload instead of vector initializer list construtor?
#include <vector>
#include <iostream>
using namespace std;
int main()
{
vector<char> v1 = { size_t(0),0 };
vector<char*> v2 = { size_t(0),0 };
cout << v1....
0
votes
0
answers
26
views
How would you test RegisterApplicationRestart()
I've been struggling with this little issue for years and thought it was time to tackle it.
I have a few MFC/C++ apps that sit running in the system tray. Occasionally, they just go away. It looks ...