Category "c++"

isPalindrome homework exercise

Write a program that uses the function isPalindrome given in Example 6-6 (Palindrome). Test your program on the following strings: madam, abba, 22, 67876, 4

Should virtual dispatch happen when a virtual method is called within a virtual method using object?

struct B { virtual void bar () {} virtual void foo () { bar(); } }; struct D : B { virtual void bar () {} virtual void foo () {} }; Now we call foo()

C++ What is the difference between definition and instantiation?

What is the difference between definition and instantiation? Sub-question: Are "variable definition" and "variable instantiation" the same? int x; The above

String plus Char - what is happening?

I'm just curious about what is going on when trying to add a char to a string. Initially, I thought it would work like a concatenation but it didn't: cout<&l

Serializing a class which contains a std::string

I'm not a c++ expert but I've serialized things a couple of times in the past. Unfortunately this time I'm trying to serialize a class which contains an std::st

How to compile a c++ program in Linux?

I made a file hi.cpp and I wrote the command given below: #include <iostream> using namespace std; int main () { cout << "Hello World! "; cout

Creating conan test_package recipe

I'm currently playing around with conan. So I've created two small project: The first project is a small library "fcdk": https://github.com/lmarzull/fcdk/tree/d

c++11/regex - search for exact string, escape [duplicate]

Say you have a string which is provided by the user. It can contain any kind of character. Examples are: std::string s1{"hello world"); std::

comparator for sorting a vector contatining pointers to objects of custom class

By this question I am also trying to understand fundamentals of C++, as I am very new to C++. There are many good answers to problem of sorting a vector/list of

How do I invoke a C++ Arduino library from rust?

It has been possible to build apps for Arduino and Teensy written in Rust for a while. You can find lists of peripheral libraries ( https://github.com/rust-embe

protocol buffers - store an double array, 1D, 2D and 3D

How can be an array of double (1D) stored using protocol buffer? What about multi-dimensional (2D or 3D) dense arrays?

What is the size of a pointer?

Is the size of a pointer the same as the size as the type it's pointing to, or do pointers always have a fixed size? For example... int x = 10; int * xPtr = &a

How to correctly set rpath to shared library with CMake?

How can I link OpenNI (libOpenNI2.so) at run time to my C++ program? This question/answer is most relevant to my question. I followed it and prepared the follow

Clangd in VSCode: .clang-format and .clang-tidy files

I've been trying to setup my VSCode to work with Clangd as a LSP server for my Cpp projects. I've successfully established basic functions such as the LSP itsel

In node-gyp binding.gyp file, how to include different library files based on the system arch (32 bit, 64bit))

I am currently trying to connect c++ with nodejs project using node-gyp. My current problem is that i have a 32 bit library file and a 64 bit library file. My c

How can I print value of std::atomic<unsigned int>?

I am using std::atomic<unsigned int> in my program. How can I print its value using printf? It doesn't work if I just use %u. I know I can use std::cout,

Anaconda ImportError: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found

I am getting the following import error when I am trying to run a Python script in a conda environment (squad) azada@scholar-fe00:~/Desktop/Toy-Problem-Team-2 $

Efficiently maintain slightly different (logging/non-logging) functions

I have a number of algorithms for community detection on graphs that I want to now visualise them. This visualisation requires me to 'hijack' these algorithms

What is the no-undefined-behavior way of deserializing an object from a byte array in C++11 (or later)?

To overcome alignment issues, I need to memcpy into a temporary. What type should that temporary be? gcc complains that the following reinterpret_cast will br

Problem with EOF when determining stream end

When I try to determine end of file with function feof(FILE *), I find it does not work as I expected: an extra read is required even if the stream does end. E.