814,841 questions
Advice
0
votes
3
replies
56
views
Pearson HW Chapter 6 Functions
I need help with my homework. I'm not sure what I'm doing wrong. Here is what the homework prompt is: Write a complete C++ program that allows the user to input and sort two values of a selected data ...
-9
votes
0
answers
66
views
How to guarantee that vector element will not be found? [closed]
I believe this picture will indicate the problem I'm experiencing:
Only when the string is not found then the loop should perform. And clearly this is not the case here.
So how to ensure that the ...
Advice
0
votes
2
replies
120
views
C++ convert vector element to string
Why can't you just do this?
int index = 0;
std::string example;
std::cin >> example;
std::vector<std::string> list;
list.push_back(example[index]);
I'm a complete beginner in c++ and I ...
-8
votes
0
answers
101
views
Why do I need extra commands for printing documents? [closed]
I'm supposed to be taking over a server application which is sending documents to a printer. It does the following:
if (OpenPrinter((LPTSTR)printer, &hPrinter, nullptr))
{
wchar_t ...
4
votes
2
answers
102
views
Passing nlohmann::json objects by value
A similar quesion Passing JSON object by value or reference doesn't have an answer but in comments Niels Lohmann himself states:
I would try not to pass by value. The internals are vectors/maps/...
1
vote
0
answers
64
views
How to open a PWA with path and query parameters using ShellExecute
I want to open a web app installed through Microsoft Edge using ShellExecute. I want to pass a path and some dynamic query parameters to the web app but this doesn't seem to work.
For example, I ...
1
vote
0
answers
94
views
Why does order of defining hidden friend binary operator- vs operator==, and using int vs concepts matter to NVCC?
I'm trying to create a pointer like type wrapper for CUDA device pointers, but ran into a problem I can't reproduce with other compilers in regular MSVC or GCC. Basically, depending on the order I ...
9
votes
2
answers
717
views
Is type qualifier on return type meaningless?
If I have a function template returning const-qualified type (with a trivial body for example):
const auto f(auto) { return 1; }
and I want to get a pointer on a particular instance of the function
...
1
vote
3
answers
197
views
Virtual range initializer in C++ to be used in range-based for loop
I want an abstract class range initializer that can be used in a range-based for loop. Is such a thing even possible? Currently I only see how to do that with non-abstract classes.
Class TestRange ...
-1
votes
0
answers
100
views
The PortName of my printer seems to be an IP address, is this the reason my application doesn't print? [closed]
I have a C++ application that is trying to send something to a printer in order for it to be written. That application is working fine with a lot of customers, so the code is ok.
While checking the ...
Best practices
0
votes
8
replies
131
views
Space optimization problem for palindrome check of a number
I was recently solving the basic palindrome number check question on leetcode and wasn't able to find an optimal solution for space complexity. It wasn't space optimized. Can anybody analyse this code ...
0
votes
1
answer
116
views
How to declare and define a generic template flip_map function?
I have the following in a header file:
template <typename A, typename B>
pair<B, A> flip_pair(const pair<A, B> &);
template <typename A, typename B, typename Cmp = less<...
11
votes
2
answers
649
views
How to stop member function returning T& being defined for T = void (and is supposed to be)
I'm trying to create a pointer like type wrapper for CUDA device pointers, but ran into a problem trying to define T& operator[]. By default, the compiler complains that I'm attempting to "...
Advice
0
votes
12
replies
87
views
Pulling in an include path from within a C++ project's source
I have the following directory structure for a C++ project:
external
eigen-5.0.1
Eigen
source
<source files>
When compiling, I add both external/eigen-5.0.1 and source to the -...
-4
votes
0
answers
58
views
Cmake cand find CSeriaPort installed using VCPKG [closed]
Cannot find directory 'cserialport' in search paths:
C:\Program Files\JetBrains\CLion 2025.3.3\bin\mingw\lib\gcc\x86_64-w64-mingw32\13.1.0\include\c++
C:\Program Files\JetBrains\CLion 2025.3.3\bin\...