logo
down
shadow

CPP QUESTIONS

Static order initialization fiasco, iostream and C++11
Static order initialization fiasco, iostream and C++11
Hope that helps According to C++11 specification: , The full quote of the paragraph includes:
TAG : cpp
Date : October 27 2020, 04:13 PM , By : محمد ابوزيكا
Difference on address of const reference to ternary operator between clang and gcc
Difference on address of const reference to ternary operator between clang and gcc
wish helps you My answer from this other question from today covers your cases in detail. I'll avoid repeating myself and just summarize.If we factor out the templates you have two cases. Case 1:
TAG : cpp
Date : October 26 2020, 11:58 AM , By : ZXSpectrum6
C++ program Exits when deletes an char array
C++ program Exits when deletes an char array
I think the issue was by ths following , You have said activeBuffer = new s_payload[...], so you could legitimately say delete[] activeBuffer. However, data is an array, not a pointer, within each s_payload element of activeBuffer. Therefore, you don
TAG : cpp
Date : October 26 2020, 11:58 AM , By : DoreenBZ
Increase efficiency - parse integers from string C++
Increase efficiency - parse integers from string C++
this one helps. To be "more efficient", you will have to profile. Here is another solution:
TAG : cpp
Date : October 26 2020, 11:58 AM , By : SandeepGorule
QSerialPort only reads correctly after second open
QSerialPort only reads correctly after second open
it should still fix some issue Most likely what the problem here is that you're setting the settings on the serial port after you have opened it. Therefore, there's a small period of time where your settings could be in an odd state. It works the sec
TAG : cpp
Date : October 26 2020, 11:58 AM , By : sourav.py
Differences between looping with an integer or an iterator in C++
Differences between looping with an integer or an iterator in C++
may help you . The primary reason for iterators is to provide generality. In particular, a generic algorithm can traverse a variety of containers using an iterator whose type is passed as a template parameter:
TAG : cpp
Date : October 26 2020, 11:58 AM , By : JosAl
2D Vector A* Search
2D Vector A* Search
I wish this helpful for you Segmentation fault is caused by the line mapData[0].push_back(line);. When you attempt access to mapData[0] it has not been initialized yet. The following solves your segmentation fault error, but I did not give thought to
TAG : cpp
Date : October 26 2020, 11:58 AM , By : F.Perl
OpenCV: Grayscale color reduction
OpenCV: Grayscale color reduction
will be helpful for those in need This is a color quantization. This is a simple technique to reduce the number of colors in an image that relies on the integer divisionSince the starting range has 256 values, if you want to end up with N colors, you
TAG : cpp
Date : October 25 2020, 07:20 PM , By : bigjbomb
STL::container, Polymorphism
STL::container, Polymorphism
it fixes the issue C++ defines a polymorphic class as a class which has at least one virtual function. typeid doesn't do anything special unless its argument is a polymorphic class. So first, add a virtual destructor to car:
TAG : cpp
Date : October 25 2020, 07:20 PM , By : Hugo
How to represent C++ function name in regular expression?
How to represent C++ function name in regular expression?
I wish this help you Instead of just giving you a cryptic expression, I'll go into detail the process of coming up with it as well. Much like a compiler parses code, you can compose a regular expression based on a sequence of tokens (which creates a
TAG : cpp
Date : October 25 2020, 07:20 PM , By : stypex
C++, pattern to initialize classes
C++, pattern to initialize classes
it fixes the issue One standard pattern for initialisation in C++ is the nifty-counter pattern. See http://www.petebecker.com/js/js199905.html. To summarise, in your header file you define an object with a constructor, so this constructor will be exe
TAG : cpp
Date : October 25 2020, 07:20 PM , By : Shazna Mohamed
Explanation about Constructors and Inheritence
Explanation about Constructors and Inheritence
To fix this issue Recently, I started working with classes and, today, class inheritance. I created a simple program to expand my perception of inheritance. The program calculates the average grade of a class. I understand the vast majority of the co
TAG : cpp
Date : October 25 2020, 07:20 PM , By : J.Extra
How to debug C++ code on VSCode? MacOS
How to debug C++ code on VSCode? MacOS
this will help You cannot use cppvsdbg as the debugger, unless you are using the Visual Studio Windows debugger. For Mac OS X you should be using cppdbg as the debugger type.Besides that, your program entry points to a directory, not an executable im
TAG : cpp
Date : October 25 2020, 07:18 PM , By : L SHRAWAN
c++ how to write integers to a binary file that stay 4 bytes long
c++ how to write integers to a binary file that stay 4 bytes long
wish help you to fix your issue You seem to be confused between text and binary files. The
TAG : cpp
Date : October 25 2020, 07:18 PM , By : Richard Bryant
When overload an operator in C++, how to get around with invalid conversion from 'const double*' to 'double*'
When overload an operator in C++, how to get around with invalid conversion from 'const double*' to 'double*'
Does that help Ideally, you would change the parameters of testfn to all be const. You have said in the comments that isn't an option. From your definitions here there isn't really a reason they can't be changed, but I'll ignore that for now.If you n
TAG : cpp
Date : October 25 2020, 07:18 PM , By : Josip Dorvak
Terminating an std::thread which runs in endless loop
Terminating an std::thread which runs in endless loop
seems to work fine You could use a std::condition_variable:
TAG : cpp
Date : October 24 2020, 01:32 PM , By : Momo
divide STL vector by a scalar operator overload
divide STL vector by a scalar operator overload
may help you . Operator overload declarations in C++ are sensitive to argument order. Putting the vector first in the argument list would be more conventional.Try either
TAG : cpp
Date : October 24 2020, 01:32 PM , By : David Bohbot
How to inherit some candidates of polymorphic function?
How to inherit some candidates of polymorphic function?
Does that help Without virtual, the A::foo() doesn't define a polymorphic interface.Anyway, you can make A::foo() visible via B with a using declaration:
TAG : cpp
Date : October 24 2020, 01:32 PM , By : Wasim
Compiler seeming to change my const parameter
Compiler seeming to change my const parameter
seems to work fine Your class template DynamicArray deduces the type E as Joint *, and in the member function Contains you basically add a const to it. Now, as it was mentioned in the comments and already stated by the compiler error, this does not l
TAG : cpp
Date : October 24 2020, 01:32 PM , By : Jay Trujillo
Trying to downcast pointer of object in std::vector
Trying to downcast pointer of object in std::vector
this will help as I understand the cast would be supposed to work since m_Current ... is a local_project object.
TAG : cpp
Date : October 24 2020, 01:32 PM , By : mazzus
CMake Error: MYSQL_INCLUDE_DIR not found
CMake Error: MYSQL_INCLUDE_DIR not found
wish helps you The default CmakeList.txt provided in sqlpp11-connector-mysql is perfect. I don't need to edit it.Apart from that i needed to install libmysqlclient-dev and it work like charm.
TAG : cpp
Date : October 24 2020, 01:32 PM , By : dualRectifier
Why is the first letter of the char array being cut off during this ssl write procedure?
Why is the first letter of the char array being cut off during this ssl write procedure?
I wish this helpful for you My basic is weak, but I've a bad feeling you're consuming the first byte in the message here: Dim bytes(SecureSocket.ReadByte) As Byte, trying to use it as the size of the message. C and C++ don't advertise string length i
TAG : cpp
Date : October 23 2020, 05:39 PM , By : Dikshant Bisht
Insert JSON into Mongocxx
Insert JSON into Mongocxx
I hope this helps you . A bsoncxx::stdx::string_view can be constructed from a std::string. Simply load your file contents (assuming it contains a single JSON object) into a std::string (perhaps via std::ifstream), and pass that std::string to bsoncx
TAG : cpp
Date : October 23 2020, 05:39 PM , By : bodaciousbob
Make a member variable object modifiable but not assignable
Make a member variable object modifiable but not assignable
hope this fix your issue Not with const correctness machinery; it's too primitive for that (it's just a single bit: either "change" or "not change").You can however mark assignment private and the container a friend so that only container methods wil
TAG : cpp
Date : October 23 2020, 05:39 PM , By : hanyue ma
Reading 16 bit DPX Pixel Data
Reading 16 bit DPX Pixel Data
should help you out This file format is somewhat comprehensive, but if you are only targeting a known subset it shouldn't be too hard to extend.From your code sample it appears that you are currently working with three components per pixel, and that
TAG : cpp
Date : October 23 2020, 05:39 PM , By : jihed sioud
pass string as argument in fuction from getline
pass string as argument in fuction from getline
wish help you to fix your issue I am trying to read a file line by line and then put in variables each word of the line , See if this helps:
TAG : cpp
Date : October 23 2020, 05:39 PM , By : ThedoreR
Why isn't std::begin/end being considered here?
Why isn't std::begin/end being considered here?
This might help you The way using-directives work is ([namespace.udir]/2):
TAG : cpp
Date : October 23 2020, 05:39 PM , By : juanf515
How to make a makefile for C and C++, with sources in subdirectories
How to make a makefile for C and C++, with sources in subdirectories
it fixes the issue The basic concept of make is actually quite simple: for each file you want to be able to build, you specify what its prerequisites are, and how to construct the target file from those prerequisites. Make can figure out how to chain
TAG : cpp
Date : October 23 2020, 05:39 PM , By : Justin Diebolt
Overload a function so that it can convert a base class to a derived class as a parameter
Overload a function so that it can convert a base class to a derived class as a parameter
This might help you I am attempting to model a 3D world, which has objects of spheres and capsules inside of it. I modeled it in a way that the shape class is the base class and that the sphere and capsule classes inherit from the base class (which,
TAG : cpp
Date : October 23 2020, 05:39 PM , By : user6055386
gtkmm and FileChooserButton can't get file name
gtkmm and FileChooserButton can't get file name
will be helpful for those in need Signals and sigc::bind pass values computed at connection time. So when you do
TAG : cpp
Date : October 23 2020, 05:39 PM , By : Kelly Chang
Why is this function not returning the correct value?
Why is this function not returning the correct value?
I think the issue was by ths following , I've made a function that converts an integer input into another integer, which it returns. Specifically, it takes in a console color, and returns a corresponding color which has the same background as the inp
TAG : cpp
Date : October 23 2020, 05:39 PM , By : Leon
Why does an address sanitized build of a C++ library give non-reproducible ASAN issues in libcxx classes?
Why does an address sanitized build of a C++ library give non-reproducible ASAN issues in libcxx classes?
I hope this helps you . "If libc++ containers cross from instrumented (rebuilt with ASan) to non-instrumented code, Address Sanitizer might report container overflow false positives."If your program is linking with libraries built with libc++ without
TAG : cpp
Date : October 23 2020, 05:39 PM , By : Katy Cassidy
How can I create a program that doesn't need to rerun to get new results?
How can I create a program that doesn't need to rerun to get new results?
Does that help I just made code that calculates the multiplication tables, based on user input. The problem is that after I print the results, the program closes and I need to relaunch it to get different input and results. , Add something like while
TAG : cpp
Date : October 23 2020, 05:39 PM , By : Fields KMbewe
When to call SSL_set_verify vs SSL_CTX_set_verify
When to call SSL_set_verify vs SSL_CTX_set_verify
fixed the issue. Will look into that further Each connection can have its own ssl object while they all get inherited from one ctx object. You can see the difference here. One generally tends to have one ctx created and use the same for all TLS conne
TAG : cpp
Date : October 23 2020, 05:39 PM , By : Kai Mies
libconfig Undefined symbols for architecture x86_64
libconfig Undefined symbols for architecture x86_64
should help you out You need to link the library to your executable.As stated in the documentation add -lconfig++ to your compiler flags and it should work.
TAG : cpp
Date : October 23 2020, 05:39 PM , By : Martes Wigglesworth
Why is there no deleteLater in QByteArray?
Why is there no deleteLater in QByteArray?
fixed the issue. Will look into that further QByteArray doesn't inherit QObject, there is no deleteLater(), there is no thread affinity and it shouldn't really matter where you delete it, just make sure you don't end up with dangling pointers.
TAG : cpp
Date : October 23 2020, 05:39 PM , By : Simon Nuñez
function for validation input c++ simple
function for validation input c++ simple
seems to work fine This answer and others will tell you what code to write to fix your problem. If you should encounter similar problems in the future, try walking through your code with a debugger. (Experience helps too.) Regarding code redundancy:
TAG : cpp
Date : October 23 2020, 03:00 PM , By : Bandary Wang
unique_ptr's of zero size
unique_ptr's of zero size
like below fixes the issue I sort of found a solution but it is not very elegant. If you have a more elegant solution, please post your answer. The solution here is pretty ugly, once we get to higher dimensions.
TAG : cpp
Date : October 23 2020, 03:00 PM , By : KayeLee
Calling DuplicateOutput With D3D12Device Fails With E_NOINTERFACE
Calling DuplicateOutput With D3D12Device Fails With E_NOINTERFACE
Hope that helps DXGI DuplicateOutput does not support DirectX 12 devices yet. As you have no experience using DirectX, you should be using DirectX 11 anyhow. DirectX 12 is an API designed for graphics experts who are assumed to already be deeply fami
TAG : cpp
Date : October 23 2020, 03:00 PM , By : ALewis
Defining interfaces for functions that only accept functions
Defining interfaces for functions that only accept functions
will help you Operators only works for user defined types. Then let's make your function be!We can define a type that is basically a lambda, but with a user defined type name:
TAG : cpp
Date : October 22 2020, 02:02 PM , By : Lingjie Qiao
What does it mean when I assign {} to an already exsiting object?
What does it mean when I assign {} to an already exsiting object?
I hope this helps . Assignment operator (including compound assignment) is given special treatment in C++11, since it is included into the list of contexts where list-initialization is allowed to occur. Because of that special treatment a plain { ...
TAG : cpp
Date : October 22 2020, 02:02 PM , By : 黄显斌
Find the duplicate element from an integer
Find the duplicate element from an integer
I wish did fix the issue. I actually understood the question to mean that an integer, not an array of integers, should be given as input:
TAG : cpp
Date : October 22 2020, 02:01 PM , By : justdmm
Converting linked list from raw pointers to smart pointers
Converting linked list from raw pointers to smart pointers
hop of those help? When constructing C++ class instances, you must use new and delete, instead of malloc and free. malloc and free are C library functions, that know absolutely nothing about C++ class constructors, destructors, and everything else th
TAG : cpp
Date : October 22 2020, 02:01 PM , By : Howard Chang
Can input audio be processed by more apps at once with Qt?
Can input audio be processed by more apps at once with Qt?
hop of those help? Yes, that will work just fine, there won't be any error. Both applications will receive the same audio input data. I tested to record the same thing at the same time using Windows' voice recorder program and a simple Qt program bui
TAG : cpp
Date : October 22 2020, 02:01 PM , By : vinely
STL type/function used in gdb conditional break, will crash the program?
STL type/function used in gdb conditional break, will crash the program?
wish helps you I wish to test in my program below: when s="abc", break inside "f()" and see the value if "i". , What is going on here is that your command:
TAG : cpp
Date : October 22 2020, 02:00 PM , By : Bobby Frazier
Compilation Error Undefined symbols for architecture x86_64:
Compilation Error Undefined symbols for architecture x86_64:
Does that help I have a program that i am trying to compile from my project directory and haven't been able to wrap my head around the following error , You need to link against the tbb library you are tying to use,
TAG : cpp
Date : October 22 2020, 02:00 PM , By : Ayush Shah
return value for a static variable
return value for a static variable
Hope this helps I'm trying to use a static variable as a counter for the number of times a function has been called. Essentially, I'm having function A call function B a number of times, and I want function B to return that value to function A so it
TAG : cpp
Date : October 22 2020, 02:00 PM , By : Reshma
template deduction: const reference and const pointer
template deduction: const reference and const pointer
wish helps you So I think when f(px) above, px should be int *, but in fact it is const int *.
TAG : cpp
Date : October 22 2020, 02:00 PM , By : srinu
Is it safe to create a const reference to result of ternary operator in C++?
Is it safe to create a const reference to result of ternary operator in C++?
this one helps. First of all, the result of the conditional operator is either a glvalue designating the selected operand, or a prvalue whose value comes from the selected operand. Exception as noted by T.C.: if at least one operand is of class type
TAG : cpp
Date : October 22 2020, 02:00 PM , By : vivek sharma
C++ calculating salary issue
C++ calculating salary issue
it fixes the issue Hello I am trying to make a program that will calculate an employees bonus when given his salary and job performance, although each time i run the code the bonus is calculated to 1 regardless of the salary I input. and I have to ke
TAG : cpp
Date : October 22 2020, 02:00 PM , By : Daniel De Jess Guzma
Forcing std::vector overload instead of int overload on list with one element
Forcing std::vector overload instead of int overload on list with one element
seems to work fine Braced initializer has no type, we can't say {42} is an int or std::initializer_list. When it's used as an argument, special rules for overload resolution will be applied for overloaded function call.(emphasis mine)
TAG : cpp
Date : October 22 2020, 02:00 PM , By : satish reddy
Heap Sort from Intro to Algorithms in C++ Implementation using Vectors
Heap Sort from Intro to Algorithms in C++ Implementation using Vectors
it helps some times I ended up figuring out the indexing issues. I still couldn't get the first method to work due to the fact that I was using pointers to point at A and the size was never correct. So I stuck with my second method. Here is the corre
TAG : cpp
Date : October 22 2020, 01:59 PM , By : Dexkokiri
Print nested_exception with no nested_ptr
Print nested_exception with no nested_ptr
wish helps you I'm trying to print nested exceptions using the following example code from cppreference.com: , You may write something like:
TAG : cpp
Date : October 22 2020, 01:59 PM , By : user6056070
Qt Overriding QLabel PaintEvent
Qt Overriding QLabel PaintEvent
I hope this helps . Here is a possible implementation of a QLabel subclass that scales its pixmap content while keeping its aspect ratio. It is implemented based on the way QLabel::paintEvent is implemented.If you are using it in a layout you can als
TAG : cpp
Date : October 22 2020, 01:59 PM , By : Roshan Jain
Expected way to unit test code in an existing UWP project?
Expected way to unit test code in an existing UWP project?
seems to work fine I have encountered similar issues unit testing UWP apps this way as well, although in C.As a workaround, you could try creating a library (Universal Windows) project which will contain the classes you want to test. Reference this l
TAG : cpp
Date : October 22 2020, 01:59 PM , By : Neelu Patil
abstract declarator ‘const<anonymous class>’ used as declaration C++
abstract declarator ‘const<anonymous class>’ used as declaration C++
may help you . nullptr is now a keyword. Try naming your variable using a non-reserved identifier.
TAG : cpp
Date : October 22 2020, 01:59 PM , By : Ankit Goenka
Does _finddata_t structure return time_write as system time or it is influenced by session timezone?
Does _finddata_t structure return time_write as system time or it is influenced by session timezone?
wish helps you To troubleshoot further, next I used GetFileTime API to retrieve the the file modification time in FILETIME struct and converted the time into UTC timestamp. I got the time according the time set on my computer. I was expecting the sam
TAG : cpp
Date : October 22 2020, 01:59 PM , By : Daniah
Why is my 4-function simple C++ calculator only returning the first function?
Why is my 4-function simple C++ calculator only returning the first function?
I wish this help you I've hunted for this answer across the web and have found similar assignments given to various students, but none seemed to have my problem. That said, I'm not able to get this simple 4-function C++ calculator to do anything EXCE
TAG : cpp
Date : October 22 2020, 01:58 PM , By : Yaswanth Kadiyala

shadow
Privacy Policy - Terms - Contact Us © animezone.co