logo
down
shadow

CPP QUESTIONS

Errors with std::enable_if<>
Errors with std::enable_if<>
To fix this issue When you use std::enable_if::type literally there is nothing to be substituted. Thus, the code is always wrong and the compilers reports the error as such. SFINAE only applies if there is "S" (substitution) which ended up to "F" (fa
TAG : cpp
Date : November 19 2020, 03:54 PM , By : Michael Wahl
How to find out if we are running in main thread?
How to find out if we are running in main thread?
will help you There is no such thing as main thread. There is a thread which was launched first, but all threads are first-class citizens. By tinkering with linker flags, I can easily create a program where the thread executing main() would not be th
TAG : cpp
Date : November 19 2020, 03:54 PM , By : Katherine
Could it be the case that sizeof(T*) != sizeof(const T*)?
Could it be the case that sizeof(T*) != sizeof(const T*)?
I hope this helps . No, they can't be different. For sufficiently different T1 and T2, sizeof(T1 *) can be different from sizeof(T2 *), but if T2 is just const T1, then:
TAG : cpp
Date : November 19 2020, 03:54 PM , By : olastor
Last word repeated in a text file C++
Last word repeated in a text file C++
Hope this helps This is my code for writing and reading a text file but the problem here is that this code generating the last word again as in it is repeating the last work of the text file which it shouldn't. Can anyone tell what mistake im making?
TAG : cpp
Date : November 19 2020, 03:54 PM , By : ahrefmef
manage enum var in c (porting code from c++)
manage enum var in c (porting code from c++)
I hope this helps you . I´m trying to make a porting of a c++ code to an msp430 c code. Since I never faced enumerated type, I´m getting few problem to undestand how to manage it. This code was written from Taylor Andrews : enum list are defined as:
TAG : cpp
Date : November 19 2020, 03:54 PM , By : Ethan Lu
Not able to create mock class/object to replace the functionality of a private member object in my class for unit testin
Not able to create mock class/object to replace the functionality of a private member object in my class for unit testin
wish helps you You can do it by creating an interface IB and making class B implement that interface. Then, in class A, use pointers to this interface. That way you can change the implementation in tests and use the mock class.One more thing. Since y
TAG : cpp
Date : November 19 2020, 03:54 PM , By : Luke
Determine DBL_MIN in a loop
Determine DBL_MIN in a loop
will help you DBL_MIN is minimum normalized positive value of double. This means that this is the minimum value that has its mantissa not less than 1.0. You can still go for smaller numbers if you choose smaller mantissa.So what you get is Denormal n
TAG : cpp
Date : November 19 2020, 03:54 PM , By : Katarzyna Kaminska
Can adding extra const qualifications break functionality (assuming compilation went fine)?
Can adding extra const qualifications break functionality (assuming compilation went fine)?
I hope this helps you . As I try to apply const-correctness for my own code, I often have to add const qualifications to function definitions in other modules (written by other programmers) in order to use those functions in my own code. (see here on
TAG : cpp
Date : November 19 2020, 09:01 AM , By : Omer Saeed
C++ template specialisation, but no match found
C++ template specialisation, but no match found
Any of those help The compiler needs to see the generic declaration before you can declare a specialization, so simply change the order of the declarations.
TAG : cpp
Date : November 19 2020, 09:01 AM , By : kkcocoqq
Visual c++ 2010 Express won't debug a new project
Visual c++ 2010 Express won't debug a new project
I hope this helps you . The user "rcgldr" gave the answer in comment, the problem comes from the Avast anti-virus software. Turning it off solves the issue.
TAG : cpp
Date : November 19 2020, 09:01 AM , By : Oliver Ebersold
Deque Iterator Error
Deque Iterator Error
I wish this helpful for you Since deque< BinNode* >::const_iterator is a dependent name, you need to explicitly identify it as a type with the typename keyword:
TAG : cpp
Date : November 19 2020, 09:01 AM , By : Leonid Poliakov
Regex to strip leading zeros
Regex to strip leading zeros
I hope this helps you . The std::regex also has a regex_replace method. It can modify strings based on a given pattern and a replacement pattern.In your case, you can use backreferences to captured substrings (those substrings matched and captured wi
TAG : cpp
Date : November 19 2020, 09:01 AM , By : Gnarl Marx
Why do I get ESC successfully only by _getch()?
Why do I get ESC successfully only by _getch()?
should help you out Because std::cin.get() reads characters from the console window, however it is not possible to actually 'write' the escape character; therefor it never catches it.from cplusplus.com
TAG : cpp
Date : November 19 2020, 09:01 AM , By : Rohan Sewaney
Parameter packs not expanded with '...'
Parameter packs not expanded with '...'
like below fixes the issue Essentially, expanding a parameter pack E... produces a list E1, E2, [...], EN, one E for each element in the pack. This syntactic construct is only valid in places where lists are grammatically correct, such as in function
TAG : cpp
Date : November 19 2020, 09:01 AM , By : Amd Download
Set appropriate colours for a shape in Qt
Set appropriate colours for a shape in Qt
I hope this helps . In your UI file you have mainWindow.enabled = false (disabled). I believe this changes the color palette of the mainwindow. That's why you get wrong colors.
TAG : cpp
Date : November 19 2020, 09:01 AM , By : webbakery
unique_ptr after move and reassigning stuff
unique_ptr after move and reassigning stuff
With these it helps Yes, this is fine.Moving from an object leaves it in a valid but unspecified state; all the class invariants are maintained and operations act as specified.
TAG : cpp
Date : November 19 2020, 09:01 AM , By : beaulah
Reboot few seconds later after program termination
Reboot few seconds later after program termination
it fixes the issue I am maintaining a c/c++ program under linux, which will change BIOS settings and reboot to enable new settings. , You can try next line:
TAG : cpp
Date : November 19 2020, 09:01 AM , By : Agita Jaunzeme
Custom-collapsing template parameter space
Custom-collapsing template parameter space
will help you You can give the second template parameter for Box a default argument:
TAG : cpp
Date : November 19 2020, 12:35 AM , By : Corrado Pellegrino
How to trim following zeros from a string of scientific number in c++
How to trim following zeros from a string of scientific number in c++
fixed the issue. Will look into that further I am trying to trim zeros from strings in scientific number form: , I would use a conditional regex like this:
TAG : cpp
Date : November 19 2020, 12:35 AM , By : Varun Joshi
Using an overloaded method of the parent
Using an overloaded method of the parent
will be helpful for those in need I have two classes: Father, and Son. Son extends Father. , You can static_cast the Son to a Father:
TAG : cpp
Date : November 19 2020, 12:35 AM , By : Zheer .B Rachid
Why doesn't the following statement work?
Why doesn't the following statement work?
may help you . Today I gave a test there was the following question written and because I am new to C++, I became confused to the following question.
TAG : cpp
Date : November 19 2020, 12:35 AM , By : PaulW
What does cursive writing of a method name mean in C++ / Qt-Creator
What does cursive writing of a method name mean in C++ / Qt-Creator
like below fixes the issue According toWhy some function definitions appears in italic font in qt creator?
TAG : cpp
Date : November 19 2020, 12:35 AM , By : Tom Lewis
Google Test multi-templates - compiler error
Google Test multi-templates - compiler error
this one helps. You have two errors. The first one is that you have named your templated struct Types, which creates a problem when it is used with ::testing::Types. Lets assume you rename it to TypeDefs. Then, in the body of the test you have an err
TAG : cpp
Date : November 19 2020, 12:35 AM , By : willy
Stack overflow in C++ destructor
Stack overflow in C++ destructor
wish help you to fix your issue I try to create the detor and got a "Stack Overflow" I know why but I want that its work...
TAG : cpp
Date : November 19 2020, 12:35 AM , By : Safeera Rehman
How to overload << operator for cv::Filestorage?
How to overload << operator for cv::Filestorage?
I hope this helps you . I would like to write my MarkerDistance struct to a file, using cv::FileStorage class. , Your operator
TAG : cpp
Date : November 19 2020, 12:35 AM , By : Muhammad Junaid
Recursion assignment not giving correct output
Recursion assignment not giving correct output
it should still fix some issue In my opinion according to the description of the assignment you should define the functions the following way. First of all you need to add one more member function to the class
TAG : cpp
Date : November 18 2020, 09:01 AM , By : Parvathy Havaji
How to initialize vector size inside a constructor?
How to initialize vector size inside a constructor?
hop of those help? As you just specified C++11, in-class initialzation may be exactly what you want:
TAG : cpp
Date : November 18 2020, 09:01 AM , By : Jodzo_22
How to run a windows cmd command using Qt?
How to run a windows cmd command using Qt?
I wish this help you I have to run the following command using Qt, which will pop up the Git GUI window. , I solved my problem using following simple code segment
TAG : cpp
Date : November 18 2020, 09:01 AM , By : Anton Teremshonok
Transform data from vector to other with no default constructor
Transform data from vector to other with no default constructor
help you fix your problem What you are doing looks fine. You can avoid the explicit loop by using std::back_inserter. Also, since the elements of the original range aren't being modified the lambda's parameter should be made const:
TAG : cpp
Date : November 18 2020, 09:01 AM , By : Avinash Meena
Specifying timeout option with setsockopt() results in subsequent listen error
Specifying timeout option with setsockopt() results in subsequent listen error
With these it helps If you see a TCP state diagram like this one you see there's a state called TIME_WAIT when actively closing a socket. This state can take some time before it ends, up to four minutes according to RFC793.While the socket is in the
TAG : cpp
Date : November 17 2020, 09:01 AM , By : AONVMP
Function pointer "was not declared in this scope"
Function pointer "was not declared in this scope"
I hope this helps . You declare two different variables each named get_V, both locally inside the scope of the if statements. Once the code inside the if statement is done, those variables are no more, they have gone out of scope.The simple solution?
TAG : cpp
Date : November 17 2020, 09:01 AM , By : Urvashi Dhokiya
DX11 Losing Instance Buffer Data
DX11 Losing Instance Buffer Data
will be helpful for those in need I've got a function that basically creates different instance buffers into an array for me to use in my DrawIndexedInstanced call. , The problem lies in your subresource data.
TAG : cpp
Date : November 16 2020, 09:01 AM , By : alpro
Using sscanf to extract an int from a string in C++
Using sscanf to extract an int from a string in C++
To fix the issue you can do My function must process strings that look like say hello y(5) or data |x(3)|, and I need to be able to extract the integer shown and store it into a separate int variable called address. However, some strings passing thro
TAG : cpp
Date : November 16 2020, 09:01 AM , By : zerODoom
Determining if 5 seconds have passed
Determining if 5 seconds have passed
it should still fix some issue I'm trying to determine if five seconds have passed in a console application since the last time I checked. I think my logic is slightly off and I don't know how to resolve it. , Fixed it by putting the Lastcheck set in
TAG : cpp
Date : November 16 2020, 09:01 AM , By : Ivy Qin
What are SetupAPI,SetupAPI1,and SetupAPI2? And what the difference between them?
What are SetupAPI,SetupAPI1,and SetupAPI2? And what the difference between them?
may help you . There is no such think as SetupAPI1 and SetupAPI2. There is a library named SetupAPI. This answer you link to refers to a library named EnumSerialPort. From that page:
TAG : cpp
Date : November 16 2020, 09:01 AM , By : Paul
call to non-static member function without an object argument, C++ nodes
call to non-static member function without an object argument, C++ nodes
Any of those help If you want to call swapNode without invoking it directly on an actual object (which is reasonable) and you want it to be a class member, then you need to declare the function static. Or you can just use std::swap
TAG : cpp
Date : November 16 2020, 09:01 AM , By : ben eisenthal
Trouble with installing wxwidgets 2
Trouble with installing wxwidgets 2
Hope this helps Unfortunately wxWidgets 3.0.2 had been released before g++ 5.1 (and even before, or maybe close to, g++ 4.9), so it doesn't compile out of the box with it in C++98 mode when using it. This problem has been fixed since, but not in an o
TAG : cpp
Date : November 16 2020, 09:01 AM , By : Asif
C++ -> Assertion failure Stack
C++ -> Assertion failure Stack
I hope this helps you . After you posted your operator== code, it's obvious what is going on. That operator is calling pop on an empty stack. You have to rewrite your operator== function so it doesn't use pop. pop modifies the stack do you don't want
TAG : cpp
Date : November 16 2020, 09:01 AM , By : Praba juss Praba
Xcode 7.11 Brew Boost C++ Library, Boost comple error
Xcode 7.11 Brew Boost C++ Library, Boost comple error
this will help You're trying to include a C++ header into an Objective-C (not Objective-C++) file. Rename the file to main.mm (.mm for Objective-C++) and it should compile correctly
TAG : cpp
Date : November 16 2020, 09:01 AM , By : André Saraiva
Do I have to deallocate memory when I get a pointer to a smart pointer?
Do I have to deallocate memory when I get a pointer to a smart pointer?
hope this fix your issue Documentation for get() will state that it simply returns a non-owner pointer to the managed resource, as opposed to release(), which actually transfers ownership to the returned pointer.This is enough to answer your question
TAG : cpp
Date : November 15 2020, 09:01 AM , By : Moshiko Mayoni
Odd behavior with stdio.h, VS 2015
Odd behavior with stdio.h, VS 2015
will be helpful for those in need So my issue was what M.M suggested, my antivirus(Avast). I believe it blocks the running of any code from VS 2015, so I'll make a report. I don't think it had anything to do with stdio.h. to M.M!
TAG : cpp
Date : November 15 2020, 09:01 AM , By : Wayne Radinsky
ifstream not pulling any data in
ifstream not pulling any data in
this one helps. The problem is that:1) When find starts, your file is at the end, because after you open it, you seek it to the end in order to read the size with tellg, but you kep it at the end. Then:
TAG : cpp
Date : November 15 2020, 09:01 AM , By : Tee Sirichai
How to change the return type of an inherited class member
How to change the return type of an inherited class member
hop of those help? You can do that, but the function in B will hide the function in A. When you use someB.getSomething(), only the function in B will be seen. This is true regardless of whether the return type matches or not.You can bring A::getSomet
TAG : cpp
Date : November 15 2020, 09:01 AM , By : Parth Suri
Using "set /p" in C++
Using "set /p" in C++
should help you out system runs a new instance of the command interpreter. Setting environment variables in that process has no effect on the program's own process. And unfortunately the C++ standard library has very limited support for environment v
TAG : cpp
Date : November 15 2020, 09:01 AM , By : Vin Pallone
(C++) K-Means Clustering trouble
(C++) K-Means Clustering trouble
Any of those help You're not initializing your counts to zero in computeCentroids(), which results in undefined behaviour. Zero them along with your centroids:
TAG : cpp
Date : November 15 2020, 09:01 AM , By : gaga951
Alignment of Child is Smaller Than Alignment of Base
Alignment of Child is Smaller Than Alignment of Base
Hope that helps I have asked Intel directly. Although it could initially be reproduced by their team, after a few days, it couldn't be. Neither I nor they had an explanation. So, magic does exist, and no harm done.As to the actual substance of the qu
TAG : cpp
Date : November 15 2020, 09:01 AM , By : kotagiri vasanth kum
Do you need to de-allocate an array of primitives?
Do you need to de-allocate an array of primitives?
Hope that helps If you allocate something with new, and it isn't handed off to a smart-pointer or something for management, you have to delete it. It doesn't matter whether it's an object or a primitive type.Be careful with the word "free" here. You
TAG : cpp
Date : November 15 2020, 09:01 AM , By : areatmnetwork
Passing function to template object when initializing template in C++
Passing function to template object when initializing template in C++
seems to work fine I'm trying to write an implementation for hash map, I'm not allowed to use anything from stdlib except for iostream, string and cassert. , Managed to get it working with Neil's advice. My hash.h:
TAG : cpp
Date : November 15 2020, 09:01 AM , By : Vidhyaprakash
Accept Empty Character Space in String
Accept Empty Character Space in String
it helps some times I am trying to have a string accept a character space. However when you type something like: , Use the following to read a whole line of input:
TAG : cpp
Date : November 15 2020, 09:01 AM , By : Jason Herrmann
Getting the DataType inside an HDF5 ArrayType
Getting the DataType inside an HDF5 ArrayType
Hope that helps The method you are looking for is H5::DataType::getSuper() which you can use on array_type since H5::ArrayType inherits from H5::DataType.
TAG : cpp
Date : November 15 2020, 09:01 AM , By : Debashis Phukon
RAM consumption inside a C++ program using Sqlite3 blob
RAM consumption inside a C++ program using Sqlite3 blob
With these it helps It is an issue reported HERE.And the oficial answer is:
TAG : cpp
Date : November 15 2020, 09:01 AM , By : Nitin
How to deduce a template before a varidic template
How to deduce a template before a varidic template
I wish did fix the issue. Just put the class F parameter after the variadic class... Ts parameter.
TAG : cpp
Date : November 15 2020, 09:01 AM , By : Prachi Gandhi
What cin.ignore() does exactly?
What cin.ignore() does exactly?
Hope that helps You don't need to use ignore every time, but it is good to use after formatted input, or in cases like yours where you only read a specified amount.In your example, if I were to type in over 200 characters, any future input might be i
TAG : cpp
Date : November 15 2020, 09:01 AM , By : Diandson
Reading from numbers and letters from a file
Reading from numbers and letters from a file
like below fixes the issue i have a little problem. I try to read some numbers and letters from a file into my programm. The file looks always like this: , The following works for me
TAG : cpp
Date : November 14 2020, 09:01 AM , By : AtrumEquus
Calling an operator over a series of members variables
Calling an operator over a series of members variables
it helps some times I am looking for a method to call an operator over a series of member variables. My goal is to reduce the number of references to each variant to exactly 1. The following MWE illustrates what I have, and what I am trying to achiev
TAG : cpp
Date : November 14 2020, 09:01 AM , By : JRWC
C++ - How to declare a function template friend for a class template
C++ - How to declare a function template friend for a class template
hop of those help? You have to declare friend as a function template if you want to match the one you defined:
TAG : cpp
Date : November 14 2020, 09:01 AM , By : Deniz Gurkan
When is C++ destructor called on an object in heap?
When is C++ destructor called on an object in heap?
fixed the issue. Will look into that further To make it easier to associate when a destructor will be called and when it wont be, use this rule of thumb: When the memory for an object is being reclaimed, then the object's destructor is called (and th
TAG : cpp
Date : November 14 2020, 09:01 AM , By : Ethan Dicks
Unable to compile c++ project in terminal
Unable to compile c++ project in terminal
may help you . Driver.cpp include "BET.cpp" should be include "BET.h"Or (and this is just for completeness, not recommended), leave the include of the .cpp, but then only try to compile the one .cpp (as in g++ Driver.cpp) - since driver will include
TAG : cpp
Date : November 14 2020, 09:01 AM , By : Christine Jean Cuyon
C/C++ - efficient method of rotating an array without using build-in functions (homework)
C/C++ - efficient method of rotating an array without using build-in functions (homework)
it helps some times There's a trick to this. It's pretty weird that you'd get this for homework if the trick wasn't mentioned in class. Anyway...To rotate a sequence of N elements left by M:
TAG : cpp
Date : November 14 2020, 09:01 AM , By : Geoffrey Graybeal
Getting errors when switching my array class to a template
Getting errors when switching my array class to a template
fixed the issue. Will look into that further I created a class that created an array of ints and stored them as a vector would. I had it all working, but then I had to turn it into a template so that I could store more than just ints. I am getting th
TAG : cpp
Date : November 14 2020, 09:01 AM , By : William Rutherford

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