Questions tagged [c++]

C++ is a general-purpose programming language. It was originally designed as an extension to C, and keeps a similar syntax, but 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++17], etc.

1
vote
2answers
22 views

Placing boost socket into std::map

I was thinking that this would be straight forward but I must be missing something crucial, hence the error =O. I'm receiving the 'use of deleted function' error inside my source file. Anyhow, I know ...
0
votes
0answers
9 views

How to look inside .ktx textures?

I want to look into .ktx textures. What I mean by that is to get a texture, open it by some text editor and just watch what is inside it. That's of course a very basic example, I guess I need a bit ...
-2
votes
1answer
14 views

“setprecision()” and floating point [duplicate]

I'm trying to Run a program that converts Currency From KD to DOLLAR and EURO. The problem is I'm expecting the output to be with 3 floating numbers but the actual out put is just 1 floating number ...
0
votes
2answers
32 views

Safely convert std::string_view to int (like stoi or atoi)

Is there a safe standard way to convert std::string_view to int? Since C++11 std::string lets us use stoi to convert to int: std::string str = "12345"; int i1 = stoi(str); // Works, ...
-1
votes
0answers
31 views

For loop and fstream don't work together?

I do not understand why when I execute this code, the program ends. I have tried "infile >> Checki" by itself and it worked. I have also tried the same for loop only printing to the screen and it ...
1
vote
0answers
35 views

c++ program for rotation of matrix

Please forgive me if my question is not good ,I am new here Task : Rotate the given matrix by 180 degree Input: 1 4 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Output: 16 15 14 13 12 11 10 9 8 7 6 5 ...
0
votes
0answers
7 views

How to generate chunk mesh in voxel engine

I'm creating 3D voxel engine and I'm wondering about generating chunk mesh which will contain all blocks in chunk. This will be important in fast rendering all blocks in chunk. Here's my chunk class: ...
6
votes
1answer
49 views

Why does std::string_view create a dangling view in a ternary expression?

Consider a method that returns a std::string_view either from a method that returns a const std::string& or from an empty string. To my surprise, writing the method this way results in a dangling ...
0
votes
0answers
9 views

Force SDL_Window to be active/on top, making parent window inaccessible (like ShowDialog in WinForms)

I'm using SDL2 (specifically, a C# wrapper of SDL2 (SDL2-CS) but it has all the same features and functionality) and am trying to make a game editor with it. Everything's going really well, but there'...
-1
votes
0answers
27 views

How to fix my code only outputting no when for a simple school problem

So i have to code a basic solution that given 4 integers (x1,v1,x2,v2), which then checks to see if at any point x1=x2. x1+v2,x2+v2. My code is currently only outputting no to cases it should be ...
0
votes
1answer
46 views

Can't seem to push_back abstract objects into vector?

I am trying to create one vector for two types of users. Admin and Customer who are both derived from an abstract class, BaseUser. However I tried some of the answers provided online but I can't seem ...
0
votes
0answers
18 views

Thread safety when storing pointers to object in container

I have a question about good code practice when a mutex needs to be implemented. Consider the following code example where there is a manager class (Group) which holds a container of pointers to an ...
-1
votes
0answers
23 views

How can I fix “CL.exe” exited with code 2

So I have been following learnopengl.com but I was on the Transformations part of the website and it keeps saying "CL.exe" exited with code 2. and its making imposable to test anything because it will ...
1
vote
2answers
69 views

What happens when a class is set by reference

I'm moving from using the C-style of setting values for structs in functions via ptrs to C++ style of using object references. What I don't understand is, when I pass an object by reference, and then ...
0
votes
0answers
23 views

How to build a project that accesses a shared library written in C++ from Java/Kotlin code via JNI using Gradle?

I want to compile a Kotlin project that uses some of my already written C++ library functionality, I found out that Java Native Interface is what I need, as I can kind of write a wrapper to call ...
0
votes
0answers
15 views

DllNotFoundException for Unity3d Android c++

I'm building a very simple c++ Shared Library in Android Studio, and using CMAKE to build .so for x86, x86_64, armeabi-v7a, arm64-v8a The resulting files are called libnative-lib.so I'm using ...
0
votes
0answers
26 views

Visual Studio Platform 2015 Toolset ='v141' cannot be found Visual Studio 2019

I am trying to compile a class lib in Visual Studio 2019 and i am getting this back as an Error. Why is this so? and I have not seen a way to install in Visual Studio 2019 Enterprise
0
votes
0answers
30 views

CppFlow on windows 10

I found this interesting project on Github (https://github.com/serizba/cppflow) Which is a c++ wrapper for the tensor api written in C. However I have some issues when installing it.. I have ...
0
votes
0answers
27 views

how to convert std::ostream to QDataStream

I'm tring to copy and paste a custom object from QListView to an other window of the same application, but this class return just a std::ostream, and i don't have access to modify this class. how can ...
0
votes
0answers
16 views

CMake GLOB_RECURSE not working as expected

I have a folder structure with the following mainfolder/ folderA/a.dll folderB/subFolderB/subsubFolderB/b.dll folderC/c.dll I want to get all DLLs which are in ...
1
vote
1answer
22 views

Segmentation fault occurs when PyRun_SimpleFile is called repeatedly

I want to embed a python code written in version 3.5 in c++. Also, the python script needs to be executed as the whole script repeatedly. My code as follows. It executes well for the first iteration ...
1
vote
0answers
44 views

Tail Call Optimization (TCO) in Clang on O2

I was playing with Tail Call Optimization (TCO) and various optimization levels in clang on godbolt. I have the very simple function (lifted from here): int factorial (int x, int y){ if (x==0) ...
0
votes
0answers
16 views

TRACE_INCLUDE(TRACE_INCLUDE_FILE) No such file or directory

I am trying to build the LGK350Z phone marshmallow kernel , I found the kernel source here: http://opensource.lge.com/osSch/list?types=ALL&search=k350z When building with the command: make I ...
-2
votes
0answers
36 views

Why am I getting executable doesn't exists error in Xcode?

This error is generated at the output and there is NOTHING incorrect with the code. I can not copy the "output(error)" so I have attached the screenshot below.The error message that is displayed at ...
0
votes
1answer
64 views

How can I fix this error: Invalid operands to binary expression ('std::vector<double>' and 'double')?

I want to obtain the average of some gyro readings and it involves dividing an std::vector<double> type with a double type, but I get the following error that reports Invalid operands to ...
2
votes
3answers
73 views

Is it possible to use quotation marks for FindFirstFile() function?

I try to return a specific .xls file with FindFirstFile(). Howerver it also returns .xlsx, due to naming convention. It is possible to use "*.xls" in the file explorer to return only .xls files. Does ...
-1
votes
1answer
58 views

Segmentation fault in char array

I am trying to solve anagram problem from https://practice.geeksforgeeks.org/problems/anagram/0. When I try in my computer with custom inputs, it works fine. But when I try it in the above link, it ...
0
votes
2answers
22 views

Parsing Json using arduino-mqtt lib

I am trying to use the arduino-mqtt lib. I have this working sending the json string. The problem comes with trying to parse the string with ArduinioJson. It just returns no value. I think it may ...
2
votes
0answers
32 views

.comment section shows 3 different compilers?

I got an external .so file and I ran: objdump -s --section .comment /opt/lib64/libexternal.so It printed: Contents of section .comment: 0000 4743433a 2028474e 55292034 2e342e37 GCC: (GNU) 4.4.7 ...
0
votes
0answers
12 views

Issue with creating a meta graph (tensorflow) on C++ (MSVC 2015)

I am getting an error message (see below) when trying to load a model, created with Tensorflow, on a C++ program. Specifically, I followed instructions shown at https://joe-antognini.github.io/machine-...
1
vote
0answers
71 views

Comparing Objectnames in c++?

I want to compare two object names so that if I create two Objects "Spiders" from class Insekten I want in the method paarung() that output will be "Spider will eat the partner". I tried that in ...
1
vote
0answers
31 views

How to access Elements of a java class in c++ using JNI

Im relatively new to JNI and im given a task to print the values of elements in a Java Class in C++ using JNI. I dont know where to start. Thanks in advance! Here is the C++ code: #include "sample1....
0
votes
1answer
24 views

How to fix issue with post requests from arduino, only being received 2-3 times before failing

I'm currently trying to send data collected from sensors on an Arduino WiFi rev2, to my rails server hosted on Heroku. I do this by sending my data in a JSON format. My problem is that while my ...
-8
votes
0answers
68 views

Please help me to understand this Class [on hold]

I am new in C++. I have a code but I am not understanding it! I have a question about two lines of this code: public: static AdapterConfig* instance(); What is it? private: AdapterConfig(...
-5
votes
0answers
28 views

Problem With Banner Ad Loading in Android

I m currently Working on Cocos2dx, I implemented Admob Ads in My Game in android. There are all fine before, as per Google Policy, App Should also allow the 64 bit devices. I changed my APP_ABI as ...
-6
votes
0answers
59 views

Programming a calculation creator on windows explorer [on hold]

My company has a lot of issues with creating an organised calculation folder for our projects. Most calculations are produced in excel spreadsheets. One of the accreditations for our company has to ...
1
vote
1answer
62 views

find method giving wrong answer in c++

In the following code we have to first calculate the weights of uniform substrings present in our strings . Uniform sub strings are those which contain just one character like "a" or "aaa". The weight ...
-1
votes
2answers
56 views

How to create multiple interval timers in Linux C++

How do I create 2 interval timers in Linux in C++ or C? I’d like the first interval timer to call a function which increments a variable every millisecond and the second timer to call another function ...
1
vote
1answer
69 views

Insertion sort algorithm behaves differently when put in a function

I have the following code to implement insertion sort: int main() { const int SIZE = 10; int a[SIZE] = {8, 6, 10, 2, 16, 4, 18, 14, 12, 10}; //insertionSort(a, SIZE); // The ...
0
votes
0answers
14 views

MacOS MPI ld: symbol(s) not found for architecture x86_64

I am trying to run an mpi program on MacOS. Every time I try to do mpicc -o ./main main.cpp I get this error: Undefined symbols for architecture x86_64: "std::__1::__vector_base_common<true>::...
8
votes
2answers
198 views

Why does this compile? Returning nullptr as std::string

Due to a bug, I just found out that this code compiles fine on with Visual Studio 17 and probably on other compilers as well. Now I'm curious why? #include <iostream> #include <string> ...
2
votes
0answers
62 views

C++ Three dimensional array random access performance

I would like to boost the performance of application which stores 3D map. Currently, it uses QtreeNode as a structure for storing the map. However, accessing random position with coordinates x,y,z has ...
0
votes
1answer
33 views

Is it possible to create CMake targets and file globs after compile time?

I am using CMake to compile an external project through ExternalProject_Add. The project compiles perfectly but I need to create additional targets based on the binaries built by the project. ...
2
votes
2answers
75 views

Efficient combined min and mean computation of a vector

I need both the minimum and the mean of the values in a vector. I'm computing them separately with the following: template <class T> T Minimum(std::vector<T> & v){ return *...
1
vote
0answers
54 views

Type conversion complex variables in C++

std::complex<double> a; int t=2; a = 100; //This line upon printing, gives me (100,0) a*t; The last line in the above code is wrong because the complex class doesn't allow for multiplication ...
0
votes
0answers
10 views

How can i store results from a Row to a string object using the XDevAPI

I am using mysql connector/C++ 8.16, XDevAPI and I want to store data which I get from each row in the table into a string, but I can't. I get different errors. The following code works : mysqlx::...
1
vote
0answers
43 views

c++ polymorphism with class template, no matching function to call

I'm writing a class template that can take one of the following, int8_t, int16_t, int32_t, float and double. Here it is: #ifndef OPERAND_HPP # define OPERAND_HPP # include "IOperand.hpp" # include &...
4
votes
1answer
120 views

For Loops (C++)

Assignment: The program should ask the user to enter a positive number and display all numbers from 1 to the input value. If the number is not positive, an error message should show up asking the ...
0
votes
1answer
14 views

Apache Thrift for just processing, not server

I hope I don't have misunderstood the Thrift concept, but what I see from (example) questions like this, this framework is composed by different modular layers that can be enabled or disabled. I'm ...
0
votes
0answers
37 views

Is FLAGS_v defined implicitly in C++?

I'm trying to solve a multiple definitions error which seems to be happening because two libraries I'm using define the same thing twice. The libraries in question are pytorch and openfst. But if I ...