logo
down
shadow

CPP QUESTIONS

Find critical edges of an MST: possible with modified Prim's algorithm?
Find critical edges of an MST: possible with modified Prim's algorithm?
this one helps. This problem is easier than the problem of sensitivity analysis of minimum spanning trees, which is to determine how much each tree/nontree edge can increase/decrease in weight before the minimum spanning tree changes. The best known
TAG : cpp
Date : November 22 2020, 10:40 AM , By : jinglebell
Converting wostringstream to wchar_t* Garbles Values
Converting wostringstream to wchar_t* Garbles Values
will help you The wostringstream::str() method returns a std::wstring by value. You are not assigning that to anything, so its lifetime is temporary and ends when the expression is finished. You are calling std::wstring::c_str() to save a pointer to
TAG : cpp
Date : November 22 2020, 10:40 AM , By : user2955639
Causing segfault in program doesn't get caught by signal handler
Causing segfault in program doesn't get caught by signal handler
seems to work fine So the explanation of this is that RTEMS does not handle signals the way that I thought it does. There are some POSIX signals which are really exceptions at the hardware level. for eg. SIGSEGV, SIGBUS, and SIGFPE. The exact semanti
TAG : cpp
Date : November 22 2020, 10:40 AM , By : user2955615
Undefined symbol: _ZN7QString13toUtf8_helperERKS_ at runtime
Undefined symbol: _ZN7QString13toUtf8_helperERKS_ at runtime
it fixes the issue qmake/cmake is the way to go. But it is interesting to see how come linker succeeds and then during run, we get an undefined reference( not an unmatched dll case ). Especially since there is no preprocessor guard for toUtf8_helper
TAG : cpp
Date : November 22 2020, 10:40 AM , By : user2955560
proper usage of C dummy functions replacement in different environment
proper usage of C dummy functions replacement in different environment
fixed the issue. Will look into that further I am trying to add test functions in a suite on both windows and linux machines. On linux machines i want the real functions to be added and on windows machine i want the dummy UnsupportedFunction to be ad
TAG : cpp
Date : November 22 2020, 10:40 AM , By : user2955556
How do you save images of detected objects in OpenCV?
How do you save images of detected objects in OpenCV?
This might help you The function call that detects the face will most probably contain a boundingRectangle parameter of type vector. Use the data present in it to select the Region of Interest(ROI) if a face is detected. This selected ROI can then be
TAG : cpp
Date : November 22 2020, 10:40 AM , By : user2955555
See if length between two equal numbers in deque is even
See if length between two equal numbers in deque is even
I think the issue was by ths following , I have a deque and I want to find if the number of ints between two equal numbers is even. For example:7,13,4,6,4,13,8,10 should be false and 1,3,5,3,4,8,7,9,6,5,7 should be true. I think my program is correct
TAG : cpp
Date : November 22 2020, 10:40 AM , By : DeltaFlight
Random real in [0..1[ using Mersenne Twister
Random real in [0..1[ using Mersenne Twister
I think the issue was by ths following , This happens because the return value of newr() and newr.max() are integers and the value returned by newr() is smaller than newr.mar(). The result of the division is a zero integer which is then converted to
TAG : cpp
Date : November 22 2020, 10:40 AM , By : user2955427
Writing the contents of a map through operator overloading
Writing the contents of a map through operator overloading
seems to work fine Your operator
TAG : cpp
Date : November 22 2020, 10:40 AM , By : user2955396
Defined operator works in main() but doesn't work in class
Defined operator works in main() but doesn't work in class
it helps some times It does not work in Plane since the Punkt objects are const and the operator- function is a non-const member function.You should make operator- a const member function.
TAG : cpp
Date : November 22 2020, 10:40 AM , By : nitrazepam
Can a throw or delete expression ever be dependent?
Can a throw or delete expression ever be dependent?
it helps some times Let's go back to when typename is required. §14.6 [temp.res]/p3, all quotes are from N4140:
TAG : cpp
Date : November 22 2020, 10:38 AM , By : user2955289
C++ finding the (largest) index of the largest element in an array
C++ finding the (largest) index of the largest element in an array
I wish this helpful for you I have an array of values and a technique for finding the index of the largest element in an array. , In a for loop add an if statement. Something like...
TAG : cpp
Date : November 22 2020, 10:38 AM , By : user2955178
Can sizeof nested twice ever be a dependent expression?
Can sizeof nested twice ever be a dependent expression?
fixed the issue. Will look into that further I noticed that gcc 5.0 rejects the following code, while clang 3.6 accepts it. , I'm using a post-N4296 draft.
TAG : cpp
Date : November 22 2020, 10:38 AM , By : KarthikaEswaran
Creation of objects from a string (C++)
Creation of objects from a string (C++)
I wish this helpful for you Ok, so you can't do what you're trying to do directly in C++. There is a bit of a workaround though:You can create a map, let's call it myCities:
TAG : cpp
Date : November 22 2020, 10:38 AM , By : user2955124
OpenCV: extractor->descriptorSize() - Segfault
OpenCV: extractor->descriptorSize() - Segfault
I wish this help you I found out that the nonfree module of OpenCV was not installed. After installation I included the nonfree library include and then called cv::initModule_nonfree();. The problem is solved.
TAG : cpp
Date : November 22 2020, 10:33 AM , By : user2955060
C++ generic iterator
C++ generic iterator
like below fixes the issue You can simply use traits to remove the T type completely, allowing it to be determined automatically:
TAG : cpp
Date : November 22 2020, 10:33 AM , By : user2955034
Why HANDLE created by 'CreateEvent' isn't valid in another process?
Why HANDLE created by 'CreateEvent' isn't valid in another process?
it should still fix some issue Handles are kinda like pointers in that they're usually process-specific. It takes special actions (like using DuplicateHandle) to share them.Depending on the situation, it might just be easier to name the object and th
TAG : cpp
Date : November 22 2020, 10:33 AM , By : Jessica Hawkins
Assistance with a Memory Allocation Error in c++, linux using g++
Assistance with a Memory Allocation Error in c++, linux using g++
it should still fix some issue I've searched for others with similar problem's to mine, but they all have much different code than I. , Take another look at this:
TAG : cpp
Date : November 22 2020, 10:33 AM , By : stanicmail
Returning by reference a member of a destroyed local variable
Returning by reference a member of a destroyed local variable
To fix this issue Since foo returns its return value by value (not by reference), foo makes a copy of the vector to return. It copies from the reference it got back from getNumbers as part of the return before it destroys the local variable a, so at
TAG : cpp
Date : November 22 2020, 10:33 AM , By : FatalError
Opengl: how do I affect the lighting on a textured plane?
Opengl: how do I affect the lighting on a textured plane?
like below fixes the issue There are at least two problems that prevent you from getting good lighting. The first one should be easy to solve. The second one goes deeper.Texture combination setting
TAG : cpp
Date : November 22 2020, 10:33 AM , By : user2954963
VS2013 and Unicode literals give warnings
VS2013 and Unicode literals give warnings
will be helpful for those in need There's only one way I can repro this, saving the text to a file encoded in utf8 without a BOM. The compiler will guess at the system default codepage and trip over the double bytes in the utf8 codes produced by the
TAG : cpp
Date : November 22 2020, 10:33 AM , By : user2954962
Define macro error: expected primary-exception before 'asm'
Define macro error: expected primary-exception before 'asm'
this will help This code is supposed to provide an assert function, for debugging only, where it automatically creates a breakpoint if the assert fails (not the full code): , You're trying to use a statement as an expression. Try something like
TAG : cpp
Date : November 22 2020, 10:33 AM , By : user2954948
Multi-property sort is inverting elements
Multi-property sort is inverting elements
hope this fix your issue Your comparison functions are both broken. Neither implements the necessary strict weak ordering that std::stable_sort requires. Specifically, Irreflexivity: f(x, x) must be false. Antisymmetry : f(x, y) implies !f(y, x)
TAG : cpp
Date : November 22 2020, 10:33 AM , By : Yuval Dolev
'template argument deduction/substitution failed' after addition of an argument
'template argument deduction/substitution failed' after addition of an argument
This might help you Since clang++ shows a different (and strange) behaviour in this case, I'm not entirely sure of this answer. However, I think I can explain what's going on when using g++.Let's take a look at the following example:
TAG : cpp
Date : November 22 2020, 10:33 AM , By : sdev
copy constructor for two dimensional vector
copy constructor for two dimensional vector
it fixes the issue I want to write a copy constructor for two dimensional vector
TAG : cpp
Date : November 22 2020, 10:33 AM , By : user2954811
How can I control static analyzed compiler error messages with templated libraries?
How can I control static analyzed compiler error messages with templated libraries?
it should still fix some issue Both gcc and clang support Diagnostic Pragmas which will allow you to ignore specific diagnostic messages for a section of code. For example to disable -Wunused-variable like so:
TAG : cpp
Date : November 22 2020, 10:31 AM , By : user2954716
Source code is calling wrong template class function in c++, how to fix?
Source code is calling wrong template class function in c++, how to fix?
help you fix your problem The type of names is char const*[2]; after conversion to a pointer, it becomes char const**, not char*. You can't call the non-template function, because there is no conversion from char const** to char*.Also, of course, the
TAG : cpp
Date : November 22 2020, 10:31 AM , By : user2954700
Why does a struct have to be in the same namespace as a template class in order to compile?
Why does a struct have to be in the same namespace as a template class in order to compile?
around this issue It's not about the struct.It's about bind and Argument Dependent Lookup.
TAG : cpp
Date : November 22 2020, 10:31 AM , By : user2954663
Why is template type deduction failing here?
Why is template type deduction failing here?
Hope that helps Template arguments for types cannot be deduced, period. This is because type specializations can provide a completely different set of members, so until you know the type's template arguments you don't even know what constructors are
TAG : cpp
Date : November 22 2020, 10:31 AM , By : user2954610
Program Efficiency & Readability
Program Efficiency & Readability
I wish this help you Inspect the assembly of an optimizing compiler to reach a conclusionSee e.g. this on godbolt.com ¹
TAG : cpp
Date : November 22 2020, 10:31 AM , By : Charles DeLone
C++ console input blocks so i can't kill thread
C++ console input blocks so i can't kill thread
should help you out What you could do is using futures to allow the user to input something with a time limit. You can then insert this code into your main loop
TAG : cpp
Date : November 22 2020, 01:01 AM , By : Koukouttou
polarToCart and cartToPolar functions in opencv
polarToCart and cartToPolar functions in opencv
To fix this issue if you're using opencv3, you probably want linearPolar:note, that for both versions, you need a seperate src and dst image (does not work inplace)
TAG : cpp
Date : November 22 2020, 01:01 AM , By : jschwuchow
Remove spaces from char-array by using a function with a pointer argument
Remove spaces from char-array by using a function with a pointer argument
I think the issue was by ths following , The call to removeSpaces has no affect because you are creating a temporary buffer in the function and copying the string into that while applying the transformation. You can fix this by removing the temporary
TAG : cpp
Date : November 22 2020, 01:01 AM , By : Tom
Input numbers until -1 is inputed
Input numbers until -1 is inputed
I think the issue was by ths following , The problem is that after a complete line has been entered n is never reset to a default value and still contains -1. On the next iteration this causes the inner while loop to be skipped and temp.front() to be
TAG : cpp
Date : November 22 2020, 01:01 AM , By : user2954229
Why isn't RVO / NRVO always applied?
Why isn't RVO / NRVO always applied?
Any of those help Obviously, when an lvalue is returned by value, there is no way to not do a copy. So, let's consider only local variables. A simple reason applying to local variables is that often it is unclear which object is to be returned. Consi
TAG : cpp
Date : November 22 2020, 01:01 AM , By : user2954185
Check if type can be an argument to boost::lexical_cast<string>
Check if type can be an argument to boost::lexical_cast<string>
hop of those help? Your expression is not sufficient, as the lexical_cast function template takes everything and only reports errors via an internal static_assert. Instead test whether inserting the object into an std::ostream is valid:
TAG : cpp
Date : November 22 2020, 01:01 AM , By : AĦmệd Kặŝệm
Hide sh: -c error messages when calling “system” in c++ Linux
Hide sh: -c error messages when calling “system” in c++ Linux
wish help you to fix your issue Think that system forks a process and then executes the command you've provided. The new process inherits the descriptor from its parent and that new process is writing in its standard error.So, this code snippet may d
TAG : cpp
Date : November 21 2020, 07:31 AM , By : user2954056
Qt5 SSL support
Qt5 SSL support
I think the issue was by ths following , I am about to make a web api request: , Most likely you have to install new version of OpenSSL.
TAG : cpp
Date : November 21 2020, 07:31 AM , By : user2954029
Inheritance of composition relationship in C++
Inheritance of composition relationship in C++
I hope this helps . I quite often confront myself to this problem. Let's say I have these classes: , You could just have A have a protected constructor that takes a B*:
TAG : cpp
Date : November 21 2020, 07:31 AM , By : user2954012
How to use System functions in c++ on linux
How to use System functions in c++ on linux
I think the issue was by ths following , You use system just like any other function. The only caveat is that the command you are executing must be available on the system your application is running on and within the same context your application is
TAG : cpp
Date : November 21 2020, 07:31 AM , By : user2953997
what is the reason of this error?
what is the reason of this error?
I wish this help you The problem is that the class definitions are not visible to the compiler when you try to access members of an instance. Although you have provided forward declarations for the classes this is not enough. In the .cpp and .h files
TAG : cpp
Date : November 21 2020, 07:31 AM , By : Magdalena
Strange behavior in C++, cout statement is required to prevent app crash?
Strange behavior in C++, cout statement is required to prevent app crash?
seems to work fine The problem is that you never allocate memory for buffer in string_to_ints. Since this is undefined behavior anything can happen, includiing appearing to work when a cout is in place and not working when the cout is removed.The sim
TAG : cpp
Date : November 21 2020, 07:31 AM , By : safaa
Why isn't abs constexpr?
Why isn't abs constexpr?
seems to work fine I can't give a good reason for why abs couldn't be constexpr and apparently neither can gcc. When I use gcc 4.9.2 with this program:
TAG : cpp
Date : November 21 2020, 07:31 AM , By : Imelda Clarke
C++ Can't increment a variable
C++ Can't increment a variable
I wish this help you I'm working on an Animation class for a small game engine, and for some reason the frame counter does not want to increment, it keeps stuck at 0 or 1.
TAG : cpp
Date : November 21 2020, 07:31 AM , By : user2953825
C++ substring seems to be pointing at wrong spot
C++ substring seems to be pointing at wrong spot
help you fix your problem Short Answer Your file is encoded in UTF-8 and it has a Byte Order Mark at the beginning.
TAG : cpp
Date : November 21 2020, 01:01 AM , By : mexicanace
How change default color of text in wxRitchTextCtrl
How change default color of text in wxRitchTextCtrl
around this issue How change color default of text? wxRitchTextCtrl , I would try this:
TAG : cpp
Date : November 21 2020, 01:01 AM , By : user2953743
static variable vs stack variable: thread safety vs stack size?
static variable vs stack variable: thread safety vs stack size?
With these it helps It's not just a matter of initialization. A static variable, even one defined within a function, is a single instance that's shared by all calls to that function — even calls in different threads. If you use a static variable as a
TAG : cpp
Date : November 21 2020, 01:01 AM , By : Dee Dubs
Transforming trees in C++
Transforming trees in C++
Any of those help One way to solve the problem on having to dispatch on unique_ptr is to go back to passing around pointers the way you do in your visitor, but changing the return type to Node*, like this:
TAG : cpp
Date : November 21 2020, 01:01 AM , By : Mihail Rodrigo Marti
Make a C++ initializer automatically detect union member?
Make a C++ initializer automatically detect union member?
this will help OK, the standard still says that brace-initializing a union initializes only the first member. I suppose this puts this question more in the "Wouldn't it be nice if...?" category. , Update In my introduction I mentioned:
TAG : cpp
Date : November 21 2020, 01:01 AM , By : user2953721
c++ headers between projects
c++ headers between projects
Any of those help You can as long as you don't use templates in project A that depends on LLVM headers. You can always forward declarate the types you are using in project A headers and include the actual headers in the cpp files.Say there is a type
TAG : cpp
Date : November 21 2020, 01:01 AM , By : Theresa Pablos
Passing pointers as a parameter in C++ rather than using this pointer
Passing pointers as a parameter in C++ rather than using this pointer
wish help you to fix your issue First thing to get straight: a non-static member function is essentially just like any other function, but has an implicit parameter called this which is a pointer to the object that the member function was called on.
TAG : cpp
Date : November 21 2020, 01:01 AM , By : user2953619
How to initialize the dynamic array of chars with a string literal in C++?
How to initialize the dynamic array of chars with a string literal in C++?
may help you . I want to do the following: , Here's a solution based on std::array:
TAG : cpp
Date : November 21 2020, 01:01 AM , By : user2953598
Prevent breaking encapsulation
Prevent breaking encapsulation
like below fixes the issue As you might have seen from the other answers and comments, the answer is: It depends.In fact, it depends mainly on the usecases where your class is used. Let's stick first to the example given in the question, the comparis
TAG : cpp
Date : November 21 2020, 01:01 AM , By : user2953576
How to add color palette to BITMAPINFO
How to add color palette to BITMAPINFO
Does that help I modified the function and didn't use BITMAPINFO at all. I used RGBQUAD to write the color palette instead. Here's the solution:
TAG : cpp
Date : November 21 2020, 01:01 AM , By : aswderf sdfwerf
How to handle different header file location on different Linux distributions?
How to handle different header file location on different Linux distributions?
hope this fix your issue In my code I use a header file which unfortunately has a different location under different Linux distributions. , Keep the simpler include
TAG : cpp
Date : November 20 2020, 01:01 AM , By : matt3948
Making a particular bit "0" in C++
Making a particular bit "0" in C++
seems to work fine I'm new at programming. Recently i came across a problem in which i have to make a particular bit 0 of a number. , Just use :
TAG : cpp
Date : November 20 2020, 01:01 AM , By : user2953312
C++ spliting string by delimiters and keeping the delimiters in result
C++ spliting string by delimiters and keeping the delimiters in result
fixed the issue. Will look into that further You could build your solution on top of the example for regex_iterator. If, for example, you know your delimiters are comma, period, semicolon, and hyphen, you could use a regex that captures either a deli
TAG : cpp
Date : November 20 2020, 01:01 AM , By : user2953253
How does Priority queue compare and store the values during the push operation?
How does Priority queue compare and store the values during the push operation?
Hope that helps A priority queue is commonly implemented as a perfectly balanced heap structure. The heap can be seen as a binary tree with the only requirement that the priority of the root is higher(smaller value for your comparator) than its child
TAG : cpp
Date : November 19 2020, 03:59 PM , By : William Neel
Copy tables between sqlite databases, qt, causes error
Copy tables between sqlite databases, qt, causes error
To fix the issue you can do I want to write the contents of my SQlite database on user click to another SQlite database. For this I am trying to make connections to two databases and do select query from one db and in transaction do insert query to a
TAG : cpp
Date : November 19 2020, 03:59 PM , By : fernando zacarias
Dealing with ambiguous declarations in C++
Dealing with ambiguous declarations in C++
I wish this help you As already mentioned, you can wrap your function declaration with another namespace or you can just use the std::pair class and avoid reinventing the wheel. Also note that the std::pair class allows you to create pairs of generic
TAG : cpp
Date : November 19 2020, 03:59 PM , By : user2953031

shadow
Privacy Policy - Terms - Contact Us © ourworld-yourmove.org