Category "c++"

C++ google test fail for multi threads

I am having following C++ code and corresponding unit tests in google test. I am studying book on Modern C++ programming using Test Driven development. Below co

How the vector gets returned even though it is a local variable inside a method of a class

The vector<int> bfs is local to the method bfs_of_graph then how can we return the vector as it would be erased in the memory and only garbage values shou

Compute shared secret for ECDSA<ECP, SHA256> keys with Crypto++

I'm trying to do the following: Receive x and y coordinates of a EC public key Generate a random EC public key Compute the shared secret of the two keys I'm stu

ASSERT: "i >= 0 && i < size()" in file Qt/6.2.4/mingw_64/include/QtCore/qstring.h

i am a noob in Qt, when a push a particular push button, the project window closes and shows this error: ASSERT: "i >= 0 && i < size()" in file Q

How to find the count of sub numbers of size k which divide the number

Given a number n Find the count of the sub numbers of size x in a number num which divides num. For example, if the number is 250 and x=2 the answer will be 2 a

Convert std::vector to std::string without \0

I want to remove the vowels from a std::string with this code: # include <string> #include <vector> bool IsVowel(char c) { return ((c == 'a') |

What is an undefined reference/unresolved external symbol error and how do I fix it?

What are undefined reference/unresolved external symbol errors? What are common causes and how to fix/prevent them?

SERVER/CLIENT cannot send and recieve data on the same socket, server close server after first attempt

Hi im trying to create a backup function for my program, the idea is to copy and send all the files from one especific folder from my client to the server, the

ERROR "nonstatic member reference must be relative to a specific object

#ifndef WORLD_H_ #define WORLD_H_ using namespace std; class World{ public: friend class DoodleBug; friend class Ant; friend class Organism; i

What factors could cause bad_alloc?

I was writing an AVL tree implementation but got an error due to bad_alloc on another platform. However, the code works perfectly for me in CS50 IDE without any

Debugger executable not found error in CLion

I'm new to using CLion and when I try to debug I get an error saying Debugger executable not found: C:\Program Files\JetBrains\CLion 2021.3.3\bin\gdb\win\bin\gd

constexpr iterate over section in memory

I am trying to turn a function, createArray, into a constexpr function. This function creates an array from a contiguous section in memory marked by two arbitra

Using the dynamic_cast operator

I'm trying to understand dynamic type casting. How to properly implement the DrawAnimals and Talk To Animals functions using dynamic_cast? DrawAnimals draws ani

Programs which accept uppercase and lowercase commands as input

I'm trying to add a help/information box in my program that pops whenever someone type in a /h, /?, /help commands. I want to make sure that my program accepts

Calling C++ member functions via a function pointer

How do I obtain a function pointer for a class member function, and later call that member function with a specific object? I’d like to write: class Dog

Is there a way to decrease space utilization and potentially improve time performance for string manipulation in my C++ code?

I'm working on a string manipulation code in C++ for my assignment, where I have to find a substring within a string and essentially replace it with a newly com

Can the global offset table manually be defined?

I'm attempting to build a flat 32-bit PIC binary with the following C++ code: extern "C" { void print(const char *){} void entry_func() { print("abcd\n"); }

Ternary operator applied to class with conversion operator and delete constructor causes ambiguity

struct A { A(); A(int) = delete; operator int(); }; int main() { true ? A{} : 0; } Compile with C++20, Clang accepts it, but GCC and MSVC reject it w

Android Hal is not registered at runtime in Android R(11)

I added my hal interface in manifest.xml, vendor_compatibilityMatrix.xml, and also in device.mk. And also I have created hal.rc file as well for my hal. but at

How to use visual studio for GitHub actions?

We have a jenkins server setup in AWS on an ubuntu machine. Created two machines on windows server 2012 and each having visual studio enterprise edition install