logo
down
shadow

CPP QUESTIONS

Two template classes use each other as template argument
Two template classes use each other as template argument
wish helps you Two template classes can use each other as template argument, but if I use anything defined in one class scope, it cannot be compiled. , gcc's error message is much more informative:
TAG : cpp
Date : January 12 2021, 09:11 PM , By : Carlos Galdino
Why am I not getting any output, for my code on insertion in linked list?
Why am I not getting any output, for my code on insertion in linked list?
around this issue I am trying to create a singly linked list by inserting nodes at end, and despite having no errors I am unable to print my linked list. Please help me debug my code. , Please help me debug my code.OK lets try a dry run.
TAG : cpp
Date : January 12 2021, 09:11 PM , By : Matthew Steed
What is the correct way of implementing this custom priority_queue
What is the correct way of implementing this custom priority_queue
should help you out Comparison routines must return false if the two elements are equal, but your version returns true.Try this instead
TAG : cpp
Date : January 12 2021, 09:11 PM , By : ralph okochu
Unable to set the location for input in vertex shader
Unable to set the location for input in vertex shader
I hope this helps . The error is not related to the layout location qualifier or the vertex shader input variables respectively attributes.But the type specification is missing in the declaration of the vertex shader output variables:
TAG : cpp
Date : January 12 2021, 09:11 PM , By : mansoor
Qt: How to Access Inherited Widget?
Qt: How to Access Inherited Widget?
may help you . Your question could do with a example to make it more clear.But, if what you are doing is something like
TAG : cpp
Date : January 12 2021, 09:11 PM , By : dantino
Why same char is not equal
Why same char is not equal
Hope this helps I have a simple code. , You should change "." to '.'."" means string not a char
TAG : cpp
Date : January 12 2021, 07:00 PM , By : user182548
Why does using a range for loop gives different output than using a regular for loop in this scenario?
Why does using a range for loop gives different output than using a regular for loop in this scenario?
it should still fix some issue What I would like to achieve , i is declared as an integer So this comparison
TAG : cpp
Date : January 12 2021, 07:00 PM , By : 3NZ0
Binary tree coding problems with c++?
Binary tree coding problems with c++?
will help you , You may not reassign a reference. So this statement
TAG : cpp
Date : January 12 2021, 07:00 PM , By : Shitic
How to safely change the type of a pointer
How to safely change the type of a pointer
this one helps. I don't think casting the pointers will ever solve your problem, if the classes have virtual functions. When you call one of these, the object pointed to will 'know' (through its v-table) that it is either A or B, and call the appropr
TAG : cpp
Date : January 12 2021, 07:00 PM , By : Lord Zantor
Can I get a pointer to a pointer pointing to nullptr, is it valid
Can I get a pointer to a pointer pointing to nullptr, is it valid
like below fixes the issue I am having some doubts about the following code: , My concern is that could cause UB, as it is a nullptr
TAG : cpp
Date : January 12 2021, 08:33 AM , By : turret
Most elegant way to split a C++ TypeList
Most elegant way to split a C++ TypeList
around this issue In "modern" C++, I have a type list: , something like this may be somewhat simpler/shorter
TAG : cpp
Date : January 12 2021, 08:33 AM , By : user98832
How to access element of JSON using Qt
How to access element of JSON using Qt
it fixes the issue I have this Json object and I want to access the "duration" and show it on console using Qt : , The direct answer as follows:
TAG : cpp
Date : January 12 2021, 08:33 AM , By : James B
find the inorder traversal of the tree and print them all by negating every alternate number
find the inorder traversal of the tree and print them all by negating every alternate number
it helps some times All you might have to do , add a additional argument to keep track of alternate sign, something like following :
TAG : cpp
Date : January 12 2021, 08:33 AM , By : Mariamario
How to compile a static library with Codelite 11.0.0?
How to compile a static library with Codelite 11.0.0?
will help you As you've probably discovered, CodeLite allows you to change the type of a project in the drop-down menu from Settings -> General -> Project type.Doing so, however, does not change the name of the project target. So, if you started off
TAG : cpp
Date : January 12 2021, 08:33 AM , By : user184975
Could this publish / check-for-update class for a single writer + reader use memory_order_relaxed or acquire/release for
Could this publish / check-for-update class for a single writer + reader use memory_order_relaxed or acquire/release for
To fix this issue Your writer only needs release, not seq-cst, but relaxed is too weak. You can't publish a value for m_position until after the non-atomic assignment to the corresponding m_buffer[] entry. You need release ordering to make sure the m
TAG : cpp
Date : January 12 2021, 01:40 AM , By : Thomas Plunkett
Passing a function identifier as an rvalue reference and applying std::move() to it
Passing a function identifier as an rvalue reference and applying std::move() to it
Does that help Consider the following snippet , You move a pointer to function, not function:
TAG : cpp
Date : January 12 2021, 01:40 AM , By : Matthew Steed
The conditional operator is not allowing the program to terminate
The conditional operator is not allowing the program to terminate
Any of those help It stuck because, if the condition ((*beg)%2 == 0 (beg < nums.end()) is true, the iterator will not increment for checking further. You have only setting i=0. You should increment the iterator as well.You can use comma operator for
TAG : cpp
Date : January 12 2021, 01:40 AM , By : afds
Define a c++ string as "\"
Define a c++ string as "\"
Any of those help I need a string that only contains "\". But this doesn't seem to work since (as far as I get it) the compiler sees it as a command instead of a simple string without any meaning. , You need to escape the backslash:
TAG : cpp
Date : January 12 2021, 01:40 AM , By : Sigfrieg
memcpy on __declspec naked returns unexpected bytes
memcpy on __declspec naked returns unexpected bytes
help you fix your problem What you are observing is due to incremental linking in MSVC's Debug Mode. The address of widget_click_fix_asm isn't actually the function itself, but the address of a JMP instruction in the JMP Thunk Table. This table is us
TAG : cpp
Date : January 11 2021, 05:14 PM , By : Johannes
What is the proper way to link enums with CMake?
What is the proper way to link enums with CMake?
hope this fix your issue The LNK2019 error message has nothing to do with your enum class.The error message says that you have no definition for the public method BufferMode bufferMode(void) of your VertexBuffer. You only declared it but you never ad
TAG : cpp
Date : January 11 2021, 05:14 PM , By : Paul McKee
is it safe to use the same mutex with lock_gard and without it in other parts of code
is it safe to use the same mutex with lock_gard and without it in other parts of code
will help you Yes, you can effectively mix and match different guard instances (e.g. lock_guard, unique_lock, etc...) with std::mutex in different functions. One case I run into occassionally is when I want to use std::lock_guard for most methods, bu
TAG : cpp
Date : January 11 2021, 05:14 PM , By : LUK
How to decode MAP Invoke messages using asn1c generated code
How to decode MAP Invoke messages using asn1c generated code
may help you . The invokeId and opCode parameters are truely detected, and the parser gives us a buffer named as invokeParameters which is of type ANY.
TAG : cpp
Date : January 11 2021, 05:14 PM , By : al.
How do you write multiple lines in a .txt with recursion?
How do you write multiple lines in a .txt with recursion?
help you fix your problem Im a programming student and the Engineer told us to write an algorithm using recursion for the math problem "Hanoi Towers". That is done, Im able to print the instructions on the console, but I need to write the instruction
TAG : cpp
Date : January 11 2021, 05:14 PM , By : PepeM
Member function with strange type causing callback function mismatch
Member function with strange type causing callback function mismatch
may help you . That signature means it is a pointer to a member function rather than a regular pointer to function. In order for MonoOdometer::imageCallback to be called it needs an instance of the class MonoOdometer to call it with, but your create_
TAG : cpp
Date : January 11 2021, 05:14 PM , By : Nougat
Visual Studio optimisations break SDL graphical output
Visual Studio optimisations break SDL graphical output
like below fixes the issue I'm not sure of the exact problem, but...When the compiler sees something like this:
TAG : cpp
Date : January 11 2021, 03:34 PM , By : jaset
How to use less memory in Sieve_of_Eratosthenes
How to use less memory in Sieve_of_Eratosthenes
seems to work fine A couple of suggestions: use a bit array representing only odd numbers break the problem up into segments so the partial sieve uses much less memory
TAG : cpp
Date : January 11 2021, 03:34 PM , By : Ricardo
Covariance in Callback Parameters C++
Covariance in Callback Parameters C++
Hope this helps Encouraged by positive feedback, I post my answer here.The main idea is to treat each callback type individually e.g. mouse and keyboard.
TAG : cpp
Date : January 11 2021, 03:34 PM , By : Rohii
switch may fall through (no it may not)
switch may fall through (no it may not)
I wish did fix the issue. Consider fun(static_cast(42)). This is a perfectly well-defined conversion, but the function from your question will reach the end without returning, and your program's behavior will be undefined. That's why GCC warns that c
TAG : cpp
Date : January 11 2021, 03:32 PM , By : Alex Sadzawka
Compilation fails calling Cocoa function from C++
Compilation fails calling Cocoa function from C++
may help you . ALL, , This is actually the core question/insight:
TAG : cpp
Date : January 11 2021, 03:32 PM , By : evegter
How to handle classes with differently named member functions in algorithms?
How to handle classes with differently named member functions in algorithms?
I hope this helps . It does not make sense to change the classes Zoo and Library just for the sake of f.It will be better to create overloaded functions for the purposes of f. You can add f-specific code in those functions without affecting the class
TAG : cpp
Date : January 11 2021, 03:32 PM , By : ChrisMe
Convert QString to QJsonArray
Convert QString to QJsonArray
To fix the issue you can do There are no arrays present in the JSON string shown. Arrays are denoted by [ ] characters. Objects are denoted by { } characters.
TAG : cpp
Date : January 11 2021, 03:28 PM , By : jamerson
Data exchange finished in CPropertyPage::OnOK?
Data exchange finished in CPropertyPage::OnOK?
help you fix your problem CPropertyPage::OnOK() doesn't do the same thing as CDialogEx::OnOK().Property pages should override CPropertyPage::OnKillActive() instead. This method allows me to perform custom validation and return FALSE without calling C
TAG : cpp
Date : January 11 2021, 03:28 PM , By : user157064
Template member specialization in template class
Template member specialization in template class
I hope this helps you . If we look at n4810 ยง 13.8.3 A member function, a member function template, a member class, a member enumeration, a member class template, a static data member, or a static data member template of a class template may be expli
TAG : cpp
Date : January 11 2021, 03:28 PM , By : Michael T.
Is it not possible to assign a struct to an index of a vector?
Is it not possible to assign a struct to an index of a vector?
To fix the issue you can do I have the following code, where I have created a constructor for my struct and I am trying to assign the a struct to a particular index of a vector container. , Your error is right here:
TAG : cpp
Date : January 11 2021, 03:28 PM , By : Thierry Brunet
Why is empty unordered_map.find not returning end()?
Why is empty unordered_map.find not returning end()?
should help you out I am trying to test if a entry in a unordered_map already exists with a given key. I am using the find() function to return a iterator. The problem is that whether the unordered_map is empty (or not) it returns a 'empty' object wh
TAG : cpp
Date : January 11 2021, 03:26 PM , By : Rit Li
Template argument deduction for inheriting specializations
Template argument deduction for inheriting specializations
help you fix your problem This issue was the subject of CWG 2303. The committee decided to add wording "preferring 'nearer' base classes" and this wording was added to the working draft. So, in C++20, your example should instantiate ff(BB) whereas in
TAG : cpp
Date : January 11 2021, 03:26 PM , By : Jonathan Bernard
dlopen undefined reference
dlopen undefined reference
seems to work fine You have not linked with the dl library correctly. You are looking for the target_link_libraries command, using the pre-defined CMake variable CMAKE_DL_LIBS:
TAG : cpp
Date : January 11 2021, 03:26 PM , By : Skee
Member function of class with template arguments and default arguments outside class
Member function of class with template arguments and default arguments outside class
like below fixes the issue Outside of your class definition, it will be unclear to a function what type Allocator is, so you have to redeclare it just like you redeclared T
TAG : cpp
Date : January 11 2021, 03:26 PM , By : kameel
Is it possible to implement a non-owning "slightly smart" pointer on top of standard weak pointers?
Is it possible to implement a non-owning "slightly smart" pointer on top of standard weak pointers?
fixed the issue. Will look into that further The problem of such smart pointer is that it would be more error prone than std::unique_ptr, T* or std::weak_ptr.When you want to know if a pointer has been deleted from elsewhere by it's unique owner, in
TAG : cpp
Date : January 11 2021, 02:18 PM , By : Fred Morrison
how to configure the AcquireCredentialsHandleA correctly
how to configure the AcquireCredentialsHandleA correctly
With these it helps If using the kerberos provider you pass a SEC_WINNT_AUTH_IDENTITY, not a CREDSSP_CRED.Take a look at AcquireCredentialsHandle (Kerberos), the page you were looking at is for the CredSSP but does not make that clear.
TAG : cpp
Date : January 11 2021, 02:18 PM , By : kameel
Using private versions of global extern variables with OpenMP
Using private versions of global extern variables with OpenMP
it helps some times There seems to be a misunderstanding here of what firstprivate and related actually do. What they don't do is magically make the global variable refer to a different copy in each thread. Instead, they give you a copy in the local
TAG : cpp
Date : January 11 2021, 11:39 AM , By : Bas
Eigen Block wrong amount of columns and rows
Eigen Block wrong amount of columns and rows
will help you As per documentation https://eigen.tuxfamily.org/dox/group__TutorialBlockOperations.html :
TAG : cpp
Date : January 11 2021, 11:39 AM , By : Shrek Qian
Memory alignment rules in inheritance
Memory alignment rules in inheritance
hop of those help? I'm trying to figure it out how class alignment works in case of inheritance. Currently I understand that , This is largely implementation-dependent. In your code:
TAG : cpp
Date : January 11 2021, 11:39 AM , By : Techspirit
Is nullptr falsy?
Is nullptr falsy?
like below fixes the issue When used as a boolean expression or transformed into a boolean either explicitly or implicitly, is nullptr consistently false? Is this implementation defined or specified in the standard? , According to the C++ 17 Standard
TAG : cpp
Date : January 11 2021, 11:39 AM , By : Grant
tm_wday returns a large integer outside 0-6 range
tm_wday returns a large integer outside 0-6 range
To fix the issue you can do Looking around some more, it is expected that after a tm structure is defined, you run the function mktime() with a reference to the instance in order to update derived values such as tm_wday. So the fixed main() function
TAG : cpp
Date : January 11 2021, 11:39 AM , By : Janko
Scope a using declaration, inside a header
Scope a using declaration, inside a header
I hope this helps you . Try declaring the types in an embedded namespace inside thirdparty so that the macro is happy, then alias that namespace so that it's accessible globally:
TAG : cpp
Date : January 10 2021, 02:06 PM , By : 66.
How to specify constructor's template arguments inside a new expression?
How to specify constructor's template arguments inside a new expression?
help you fix your problem Unfortunately, you can't specify template arguments explicitly for constructor template, which can't be used unless the template parameters could be deduced. [temp.arg.explicit]/8
TAG : cpp
Date : January 10 2021, 02:04 PM , By : Nougat
Sort an array via x86 Assembly (embedded in C++)?? Possible?
Sort an array via x86 Assembly (embedded in C++)?? Possible?
With these it helps This code is in now way tested. I wrote it in notepad, which doesn't have a very good debugger, off the top of my head. It should be a good starting place however:
TAG : cpp
Date : January 10 2021, 01:57 PM , By : user179190
How to Replace only Part of the Variable using #define
How to Replace only Part of the Variable using #define
should help you out The pre-processor only operates on strings that are entire tokens. There would be chaos otherwise. Try:
TAG : cpp
Date : January 10 2021, 01:57 PM , By : Keonne Rodriguez
How do you compare the performace of valarrays vs built-in arrays?
How do you compare the performace of valarrays vs built-in arrays?
wish helps you valarray was intended to improve the chances of getting good optimization. For better or worse, it's become something of the forgotten step-child of the standard library; I don't know of any implementations that do much to take advanta
TAG : cpp
Date : January 10 2021, 01:57 PM , By : Tony Z
Is it normal for C++ static initialization to appear twice in the same backtrace?
Is it normal for C++ static initialization to appear twice in the same backtrace?
wish helps you Welcome to the "static initialization order fiasco". You should probably just read that entire article, as it will describe (in detail) how you may be running into this issue how to fix it.
TAG : cpp
Date : January 10 2021, 01:57 PM , By : brij
c++ generate a good random seed for psudo random number generators
c++ generate a good random seed for psudo random number generators
I think the issue was by ths following , The code that reads from /dev/random seems wrong: you're C-style casting the address of your character buffer into random_seed_a (plug for C++ casts here) and ignoring anything you actually read from /dev/rand
TAG : cpp
Date : January 10 2021, 01:57 PM , By : Pradeep Gowda
Why isn't my operator overloading working properly?
Why isn't my operator overloading working properly?
Hope this helps Polynomial::operator -= isn't modifying this, it's modifying a copy of this. If you change Polynomial a= *this to Polynomial a= *this, i.e., make a reference instead of a copy, it will work as you are now modifying *this through a. Al
TAG : cpp
Date : January 10 2021, 01:57 PM , By : PeteFilicetti
Getting meaningful error messages from fstream's in C++
Getting meaningful error messages from fstream's in C++
will be helpful for those in need Nobody stops you from also checking errno/strerror (e.g. in your exception handler) for a more specific reason for failure.UPDATE -- regarding portability
TAG : cpp
Date : January 10 2021, 01:57 PM , By : Dominique Vocat
C++: Converting Julian dates to Gregorian
C++: Converting Julian dates to Gregorian
will help you I stumbled across this old question, and thought I might be able to add some new information to it. The single existing answer as I write this by Thomas Pornin is a good answer, and I've upvoted it. However I've taken it as a challenge
TAG : cpp
Date : January 10 2021, 01:57 PM , By : user183275
Could someone explain this interesting behaviour with Sleep(1)?
Could someone explain this interesting behaviour with Sleep(1)?
will be helpful for those in need Thread.Sleep(0) will let any threads of the same priority execute. Thread.Sleep(1) will let any threads of the same or lower priority execute.Each thread is given an interval of time to execute in, before the schedul
TAG : cpp
Date : January 10 2021, 01:57 PM , By : techthumb
Is it possible to roll a significantly faster version of modf
Is it possible to roll a significantly faster version of modf
this will help You're getting good answers here, but where does the other 90% of time go?Don't look at exclusive % time per routine.
TAG : cpp
Date : January 10 2021, 01:57 PM , By : Mistere
Updating pointer using signals and slots
Updating pointer using signals and slots
fixed the issue. Will look into that further You're insisting on doing the wrong thing, why? Just send the Sample itself:
TAG : cpp
Date : January 10 2021, 01:57 PM , By : Ashaea
How are classes more secure than structures?
How are classes more secure than structures?
may help you . Access specifiers, such as private and public have nothing to do with security. In C++, for example, these specifications get compiled away and don't even exist in the compiled binary.Rather, access specifiers are designed to make type
TAG : cpp
Date : January 10 2021, 01:49 PM , By : Bin
finding "distance" between two pixel's colors
finding "distance" between two pixel's colors
Hope this helps Once more something relatively simple, but confused as to what they want. , I'm guessing they want you to use:
TAG : cpp
Date : January 10 2021, 01:49 PM , By : gbodunski

shadow
Privacy Policy - Terms - Contact Us © scrbit.com