Questions tagged [c++]
C++ is a general-purpose programming language. It was originally 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.
708,979
questions
1
vote
0answers
10 views
Running Code during Dialog initialization, after GUI is drawn
I'm writing an application that communicates and initializes instruments (via COM ports) during the initialization phase of a Dialog (using MFC, on Windows 10).
The instrument initialization is ...
0
votes
0answers
6 views
When can a BluetoothLE operation prompt for consent on Windows 10?
I developed a command-line program that connects to a BLE device (a motion sensor), subscribes to motion notifications, then prints the coordinates to stdout around 60 times per second. The data is ...
-2
votes
1answer
26 views
accessing a member of a child object when it is in a base vector [duplicate]
Im currrently having issues accessing a member of a child object when it is in a base vector, I know it is an object slicing issue, im trying to use dynamic casting but im a beginner and am not really ...
-1
votes
1answer
26 views
Array to Pointer in C++ [duplicate]
Why is the following code correct:
double balance[5] = {1000.0, 2.0, 3.4, 17.0, 50.0};
double *p = balance;
And why is this one not correct:
double *p = {1000.0, 2.0, 3.4, 17.0, 50.0};
Can someone ...
-3
votes
0answers
19 views
C++: Return a reference to a dynamic string created with new. Will it cause a memory leak? [duplicate]
Will this cause a memory leak:
inline std::string & foo(int x)
{
auto rstr = new std::string("UNK("+ std::to_string(x) + ")");
return *rstr;
}
Does the calling function ...
1
vote
1answer
27 views
Is there something faster than a min heap for my use case?
My use case is as follows:
I need to get the minimum of a set of growing elements; I'll only need the minimum for any iteration
I will update the minimum value after which it is guaranteed to no ...
-1
votes
1answer
23 views
How do I make multiple if statements inside one another taking user input in C++?
so I am new to programming, especially with C++ and I am trying to write a bank program, where I am currently trying to make the person an "account" asking them if they want to make a Basic, ...
0
votes
0answers
18 views
C++ How to stop private member variables constructor being called. It supposed to reference another object [duplicate]
I'm new to C++ and not an experienced programmer.
I have a class which contains a member variable of another class I have created.
I want this variable to be passed through by the user in the ...
-2
votes
0answers
16 views
Linker warning bad type for variable c cpp namespace issue
Iam facing a linker warning for an example code..
Cpp code:
1.h
namespace xx{
struct yy{
float pp[50];
};}
// End of namespace
1.cpp
#include "1.h"
{
using namespace xx;
struct yy getpp;
...
-3
votes
0answers
14 views
Why does the number 0 works on XOpenDisplay and a const char * with “0” doesn't?
My code is this the problem i'm having is that if i change the variable on the call of the function XOpenDisplay(0) from 0 to XOpenDisplay(nome) that has the "0" inside of it, it just doesn'...
1
vote
3answers
55 views
Is constexpr the new inline?
To the best of my knowledge, the inline keyword in c++ can be traced back to old compilers (then known as "optimizing compilers") not being able to optimize as well as modern ones, so ...
-3
votes
0answers
21 views
c++: Declaration of an array inside a typedef struct and just by itself gives different results/errors [closed]
I transferred parts of code that gets uploaded to an Arduino to a new project in VS Code to only test out a function.
Now after transfer I have problems with a big array containing Intel Hex code.
...
0
votes
1answer
50 views
C++ avoid dynamic memory allocation
Imagine I have some Node struct that contains pointers to the left and right children and some data:
struct Node {
int data;
Node *left;
Node *right;
};
Now I want to do some state space search,...
-1
votes
1answer
18 views
Polymorphism C++: Passing child object by value to function that accepts parrent object
I am passing a child object by value to a function that accepts a parent object.
I did not expected to work because I thought that polymorphism involving upcasting applied only for pointers/references....
-3
votes
0answers
25 views
error: 'SocketIO' does not name a type; did you mean 'socket35'? | SocketIO *sc; [closed]
I have some issue with my program. I wrote a class called SocketIO that inherits from abstract class DefaultIO. When I try to initialize a command class that I wrote, it says error: 'SocketIO' does ...