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.

768,743 questions
0votes
0answers
2views

How to install cURL into visual studio code

I've been trying to get curl into vsc since yesterday, so far I've managed to install curl and use commands in command prompt, but I have no idea how to implement it into VSC? The path if needed is C:\...
0votes
0answers
12views

C++20 : Memory allocation of literal initialization of const references

I am trying to optimize for speed of execution a piece of code using the factory design pattern. The factory will produce many objects of a class having some members that are constant throughtout the ...
1vote
0answers
10views

Best approximation for nanosecond-accurate sleep function with compile-time duration?

For a benchmarking application I want to write a C++20 function template like this: template<size_t n> void noop() { /* ??? */; } That when instantiated and executed: has no side effects. ...
0votes
0answers
2views

Creating and using UCurveFloat in Unreal Engine in C++ for FTimeline

I don't understand how I can create an object of the UCurveFloat class in C++ to pass it to the AddInterpFloat function. In .h: UFUNCTION() float GetProgressInTimeline(float val); UFUNCTION() ...
0votes
1answer
25views

Can you call a constexpr function to assign a constexpr value with a forward declaration?

I found myself in a weird spot, with the error message "expression did not evaluate to a constant": constexpr uint64 createDynamicPipelineStateMask(); static inline constexpr uint64 ...
0votes
0answers
20views

Is it faster to iterate an std::vector<int> by references to elements or by index? [duplicate]

Let v be a std::vector<int>. Which of the two methods below is faster for iterating over its elements? for (auto& el: v) {...el...} or for (size_t i = 0; i < v.size(); ++i) {...v[i]...} I'...
-2votes
0answers
18views

Why isn't the if part of this code working? [duplicate]

The else if part of my code works perfectly. But the if part doesn't show the desired result or an error. What adjustment do I need to make to have the if part work? #include<iostream> using ...
-3votes
0answers
23views

118 Leetcode| Pascals triangle| buffer overflow [closed]

I tried to solve this question on my own intuitively.The approach seems fine to me mostly however i am facing a stack overflow issue which i am not able to identify. Any help would be appreciated. My ...
0votes
0answers
19views

Executable not able to find libstdc++ version

I have different compilers installed on my machine. The default libstdc++.so is inside /usr/lib64. I installed gcc 12.1 in "/home/myCompilers/gcc1210" folder and I am using my Clion to use ...
-3votes
0answers
34views

Can we use strcpy to allocate from one memory to another? [closed]

phone_book(int num) { int i = 0; char(*call)[10] = nullptr; call = new (std::nothrow) char[num + 1][10]; stcpy(call,phone_book) for ...
1vote
0answers
18views

Set "Command" and "Command Arguments" with some paths using Bat file

As per project need, we are using bat file which sets so many environment variables and invokes Visual Studio (c++). After launching solution, every time, I'm keying-in as "./bin/App.exe" ...
-4votes
0answers
24views

How would you solve this? [closed]

Write a C++ program to solve the following problem: There a n lockers in a hallway, numbered sequentially from 1 to n. Initially, all the locker doors are closed. You make n passes by the lockers, ...
0votes
0answers
18views

Member function called, not virtual function-when object passed by value in C++ [duplicate]

I'm testing whether [passing by value] works with "virtual function call", as below: #include<stdio.h> struct B { virtual void f() { printf("Base\n"); } }; struct D : B { ...
0votes
0answers
16views

Chromium custom build network service crashed

I have rebranded Chromium project to create my own browser. I have changed the chromium icon and name. I tried to chagne the chrome url scheme (chrome://settings/* for example) to replace it with the ...
1vote
0answers
40views

C++ template: Derived class cannot resolute Base class function unless using "this->" [duplicate]

This code doesn't compile: #include<iostream> using namespace std; template<class T>struct Base { void f(int) { cout << "Base::f() int\n"; } }; template<class T>...

153050per page