logo
down
shadow

CPP QUESTIONS

If a 32-bit integer overflows, can we use a 40-bit structure instead of a 64-bit long one?
If a 32-bit integer overflows, can we use a 40-bit structure instead of a 64-bit long one?
I hope this helps you . Yes, but... It is certainly possible, but it is usually nonsensical (for any program that doesn't use billions of these numbers):
TAG : cpp
Date : November 19 2020, 03:59 PM , By : Margaret W
How do I use function pointers within this class?
How do I use function pointers within this class?
Does that help From the error message, it appears that draw is a generic pointer to a function, and not a pointer to a member function. The declaration of draw should be void (X2D::GL::Circle::*draw)(void), so that draw points to a member function of
TAG : cpp
Date : November 19 2020, 03:59 PM , By : user2952921
How to Pass points to cvFitEllipse2 in OpenCV
How to Pass points to cvFitEllipse2 in OpenCV
this one helps. I am new to OpenCV, I have array of CGPoints and I need to pass those values to cvFitEllipse2, how to pass those values? Right now I am getting exception if I pass like below , try this:
TAG : cpp
Date : November 19 2020, 03:59 PM , By : Philip Bijker
opengl rendering pixels gives white lines
opengl rendering pixels gives white lines
like below fixes the issue at n.m. tip i added glEnable(GL_BLEND); glEnable(GL_POINT_SMOOTH); glHint(GL_POINT_SMOOTH_HINT, GL_NICEST); at the end of my init and it worked!
TAG : cpp
Date : November 19 2020, 01:01 AM , By : user2952754
Vim omnicppcomplete 'using namespace' issue
Vim omnicppcomplete 'using namespace' issue
I wish this helpful for you I apologise if this question has been asked before, I had a quick look but I had trouble finding specific enough search terms. , String should be string. C++ is case-sensitive.
TAG : cpp
Date : November 19 2020, 01:01 AM , By : Daniel D.
Return a reference to a Armadillo vector element
Return a reference to a Armadillo vector element
Hope this helps at(0) is almost certainly returning a proxy object, which can be converted to double, or be assigned a double, but is not actually a reference. This may be to avoid dangling references, or to allow for efficient storage of sparse matr
TAG : cpp
Date : November 19 2020, 01:01 AM , By : Rizwan Hassan
Initializing multidimensional array C++
Initializing multidimensional array C++
I hope this helps . In C++, when I want to initialize an array of some length (of integers for instance) I can just write , Using std::vector is the safe way:
TAG : cpp
Date : November 19 2020, 12:41 AM , By : bd1234
Injecting a hook DLL into a process before its imports get called?
Injecting a hook DLL into a process before its imports get called?
will be helpful for those in need You can create the target process suspended and use CreateRemoteThread() for injection, but mind the following limitations: You should copy the thread main routine for the remote thread to the address space of the ta
TAG : cpp
Date : November 19 2020, 12:41 AM , By : user2952237
Why can't I pass this class as a reference when returned from arithmetic operators?
Why can't I pass this class as a reference when returned from arithmetic operators?
I hope this helps . You're creating arithmetic operators with a side affect... These operators shouldn't change the value of the arguments used.And, to the answer your question, these methods return a temporary object, that can't be passed as referen
TAG : cpp
Date : November 19 2020, 12:41 AM , By : WB-ZA
C++: how to do "map" of Scheme
C++: how to do "map" of Scheme
it should still fix some issue There is no predefined exact equivalent... but it's not difficult to write:
TAG : cpp
Date : November 19 2020, 12:41 AM , By : TAchim
invalid conversion from ‘char’ to ‘const char*’
invalid conversion from ‘char’ to ‘const char*’
wish helps you Seems to be something wrong with string slicing text[i], what's wrong with that ? , This line is the problem:
TAG : cpp
Date : November 18 2020, 03:49 PM , By : user2952029
C++ call public parent class method via its derived class object
C++ call public parent class method via its derived class object
may help you . I have a base class that I defined like this: , You need to change it from private to public inheritance:
TAG : cpp
Date : November 18 2020, 03:49 PM , By : baronju
C++ Macros with multiple statements
C++ Macros with multiple statements
Does that help I am analyzing the source of the FileTransfer open source project from sourceforge. I'm new to C++ and I came across the following macro: , It just replaces he occurrence of
TAG : cpp
Date : November 18 2020, 03:49 PM , By : mr duc
Name conflict between member function and class name
Name conflict between member function and class name
may help you . There are a few ways to disambiguate a base class hidden by a method name.
TAG : cpp
Date : November 18 2020, 11:13 AM , By : Reakins
Creating a tree using std::array
Creating a tree using std::array
wish helps you As noted in the other answers, the fundamental problem here is that you are using a type inside the definition of that type.The reason this is a problem is because the compiler must know how big a type is in order for you to have it as
TAG : cpp
Date : November 18 2020, 11:13 AM , By : Sarah Adams
Using auto as the return value with my function in c++ isn't working in CodeBlocks
Using auto as the return value with my function in c++ isn't working in CodeBlocks
wish help you to fix your issue Either your compiler does not support C++11, or that support is not enabled and you need to add some compiler options. You haven't told use which compiler version you're using, so I can't say which of these two possibi
TAG : cpp
Date : November 18 2020, 11:13 AM , By : RajaRam Krishnamurth
C++ vector.push_back adds objects twice when adding an object once
C++ vector.push_back adds objects twice when adding an object once
I wish this help you There is nothing in the code shown that would make objects be inserted twice, so it comes down to some old-fashioned debugging skills. For a start, change the loader function to be something like:
TAG : cpp
Date : November 18 2020, 11:13 AM , By : Tanvi Nishchal
MSBuild error: The command exited with code 255
MSBuild error: The command exited with code 255
it should still fix some issue There is a difference when running commands in a batch script. You need to double your % signs. Try this:
TAG : cpp
Date : November 18 2020, 11:13 AM , By : user2951589
Converting a char* into an int
Converting a char* into an int
Hope this helps I'm currently trying to convert an integer into a char* in order to send it over a socket. In the receiving method I logically try to treat the char* as an integer again, but I seem to be missing something because I can't get it right
TAG : cpp
Date : November 18 2020, 11:13 AM , By : swapon
Unscoped enumerators within a class definition
Unscoped enumerators within a class definition
fixed the issue. Will look into that further As known, static data members shall not be defined in the class definition: , [class.mem]/p1:
TAG : cpp
Date : November 18 2020, 11:13 AM , By : user2951443
understanding break statement and handling it for existing code
understanding break statement and handling it for existing code
I wish this help you In the below example, i have problem in handling the break statement. For country = US, somearray will be of length one only. but in case of "DE", length is more than one. but given program, since break statement is used to get o
TAG : cpp
Date : November 18 2020, 11:13 AM , By : Shivang Parekh
Linker LNK2005 Error
Linker LNK2005 Error
I hope this helps you . In include "Main.h" you have defined bool Init;, so every-time you include Main.h, you will get Init redefined. If you make Init static,
TAG : cpp
Date : November 18 2020, 11:13 AM , By : Jon
Model transformations
Model transformations
This might help you Model/world transform is specific to each mesh/model in your scene. Like you mentioned, to transform each model independently, having a matrix for each is apt.As for the vertex shader, you could have the projection-view matrix in
TAG : cpp
Date : November 18 2020, 01:01 AM , By : Ron
Template with OO caused unresolved external symbol issue
Template with OO caused unresolved external symbol issue
this one helps. It's your static variable in your class. You only declare it in your header but you also need to define it in your cpp file. That means you will have to include your template static member in the cpp.E.g. in your cpp file do this:
TAG : cpp
Date : November 18 2020, 01:01 AM , By : user2951372
How to hash a buffer with std::hash?
How to hash a buffer with std::hash?
To fix the issue you can do The idea with std::hash is to provide a general hashing algorithm for fixed-size data that is good enough for most uses, so users don't need to roll their own every time. The problem with variable length inputs is that has
TAG : cpp
Date : November 18 2020, 01:01 AM , By : user2951349
Closest Pairs by sweeping vertically
Closest Pairs by sweeping vertically
it fixes the issue It does work correctly(because the points are deleted from the set only when they can be safely deleted). However, it has O(n ^ 2) time complexity, because the points are not always deleted when they should be.This simple generator
TAG : cpp
Date : November 18 2020, 01:01 AM , By : zhang935989088
Nested calling vs. Calling step by step
Nested calling vs. Calling step by step
seems to work fine You should go for clarity - the compiler should optimize the temporary away. But if it's critical, benchmark and look at the assembly code.
TAG : cpp
Date : November 18 2020, 01:01 AM , By : kongy
std::unordered_map::emplace behavior with no move/copy constructor
std::unordered_map::emplace behavior with no move/copy constructor
like below fixes the issue You seem to have some misunderstanding about basic terminology. A default constructor is one that can be called with no arguments. FooBar(int* pFoo, int* pBar) is not a default constructor.Moreover, to get your code to comp
TAG : cpp
Date : November 18 2020, 01:01 AM , By : user2951243
Engine to render different types of graphic objects
Engine to render different types of graphic objects
I hope this helps you . I am a huge fan of templates, but you may find in this case that they are cumbersome (though not necessarily the wrong answer). Since it appears you may be wanting diverse object types in your drawing container, inheritance ma
TAG : cpp
Date : November 18 2020, 01:01 AM , By : ImreFitos
Do objects iniside objects get stored in the stack or heap when it does not use the new keyword but the parent object is
Do objects iniside objects get stored in the stack or heap when it does not use the new keyword but the parent object is
will help you The B is part of the A. So wherever the A is stored (be it stack, heap or whatever), that is, by definition, where the B is stored.
TAG : cpp
Date : November 18 2020, 01:01 AM , By : Josh
Why doesn't while (*s++=*t++); work for me?
Why doesn't while (*s++=*t++); work for me?
Any of those help You can't increment an array. What would that even mean?Try this:
TAG : cpp
Date : November 18 2020, 01:01 AM , By : Benjamin Budzak
Do I need locks to write into socket using the same application twice and simultaneously?
Do I need locks to write into socket using the same application twice and simultaneously?
hop of those help? No, you should not use locks for writing in this case. Think about it: how would two programs written by two different companies work on the same machine if they needed to take locks before writing to independent sockets?Even writi
TAG : cpp
Date : November 18 2020, 01:01 AM , By : user2951101
bind binded function as argument
bind binded function as argument
it should still fix some issue The primary problem is that your bar_cb(T) doesn't deduce the template argument because the template argument is actually specified when using foo::template bar_cb with some template argument X. The bind() expression wi
TAG : cpp
Date : November 18 2020, 01:01 AM , By : John Ades
How to read exactly one byte in a binary file in C++
How to read exactly one byte in a binary file in C++
This might help you x is not initialized, and you modify only one byte of it, so you have garbage for the other bytes.Use directly the correct type should solve your issue (and avoid a cast).
TAG : cpp
Date : November 17 2020, 11:58 AM , By : user2951035
Ignore "still reachable" when setting return value
Ignore "still reachable" when setting return value
Any of those help In a CI system I run a bunch tests with valgrind, where I expect return value 0 if no errors are found by valgrind and 1 otherwise. The tests itself run successfully and return 0. , TL;DR: Use
TAG : cpp
Date : November 17 2020, 11:58 AM , By : Jordan Thomas-Davies
Class with private constructor and static array of itself
Class with private constructor and static array of itself
To fix the issue you can do Sorry if title is confusing, I couldn't find an easy way to write it in a simple sentence. Anyways, the issue I'm facing: , The solution:
TAG : cpp
Date : November 17 2020, 11:58 AM , By : user2950975
Implementation of getline in a while loop comparison
Implementation of getline in a while loop comparison
it fixes the issue The problem with your code is that getline(std::cin, str) returns a istream , which is not a string literal. For more information on std::getline.
TAG : cpp
Date : November 17 2020, 11:58 AM , By : user2950968
shared_from_this causing bad_weak_ptr
shared_from_this causing bad_weak_ptr
I wish did fix the issue. I am trying to keep a list of connected clients in asio. I have adapted the chat server example from the docs (http://www.boost.org/doc/libs/1_57_0/doc/html/boost_asio/example/cpp03/chat/chat_server.cpp) and here's the impor
TAG : cpp
Date : November 17 2020, 11:58 AM , By : user2950952
fast heuristic algorithm for n queens (n > 1000)
fast heuristic algorithm for n queens (n > 1000)
I wish this helpful for you Note: This answer assumes you're interested in finding one valid solution. If you need to find all solutions, this won't help you.Artificial Intelligence: A Modern Approach, Second Edition by Russell Norvig has a table in
TAG : cpp
Date : November 17 2020, 11:58 AM , By : Bryant Ezroj
2 Dimensional Char Array C++
2 Dimensional Char Array C++
will be helpful for those in need The problem is with board[i][j] = {"||"}; . The string "||" cannot be implicitly converted to a single character.It's not clear what you are trying to do; each cell of the board is a char, and || is two chars. Two do
TAG : cpp
Date : November 17 2020, 11:58 AM , By : user2950908
How to speed up counting the occurences of a word in large files?
How to speed up counting the occurences of a word in large files?
fixed the issue. Will look into that further Assuming there are no insanely large lines in the file using something like
TAG : cpp
Date : November 17 2020, 11:58 AM , By : user2950867
Newton's binomial - doesn't work for bigger numbers
Newton's binomial - doesn't work for bigger numbers
Does that help Factorial grows really fast and even unsigned 64-bit integers overflow n! for n>20. The overflow free way to implement the binomial coefficient is to use this recursive definition:
TAG : cpp
Date : November 17 2020, 11:58 AM , By : user2950816
Weird behavior of printf in C++ with a newline character
Weird behavior of printf in C++ with a newline character
hope this fix your issue To explain what you are seeing from argv[1] + '\n'. This is pointer plus integer (character constants have type int in C).The definition of that in C is that the pointer is advanced by as many units as are in the integer. \n
TAG : cpp
Date : November 17 2020, 11:58 AM , By : user2950785
How to convert an OpenCV Mat that has been written in an xml file back into an image?
How to convert an OpenCV Mat that has been written in an xml file back into an image?
I wish this help you you can convert it to matlab format within opencv.read it in using the Filestorage:
TAG : cpp
Date : November 17 2020, 11:58 AM , By : Petr Attritions Baye
Strange program behavior
Strange program behavior
I wish this helpful for you So I wanted to write code which solves this problem: "Collecting Beepers" And I did: , That is propably because your variable "current" is overriden. Try:
TAG : cpp
Date : November 17 2020, 11:58 AM , By : user2950742
Deadlocks related to scheduling
Deadlocks related to scheduling
I wish this helpful for you The document is addressing a specific kind of fairness problem and is lumping it into its discussions about deadlock. The document correctly defines deadlock to mean a "permanent blocking of a set of threads". It then desc
TAG : cpp
Date : November 17 2020, 11:58 AM , By : Stephen Ricciardelli
C++ homework (while loop termination)
C++ homework (while loop termination)
wish of those help Instead of reading val1 and val2 directly from stdin, read a line of text. If the line does not start with |, extract the numbers from the line using sscanf or istringstream. If the line starts with |, break out of the while loop.
TAG : cpp
Date : November 17 2020, 11:58 AM , By : Sandra Salamanca
How to make a constant or variable accessible in entire program
How to make a constant or variable accessible in entire program
To fix the issue you can do You really do not want to use that particular approach and include that code in all translation units. If you did each one would include two variables named desktopWidth and desktopHeight causing duplicate symbol errors du
TAG : cpp
Date : November 17 2020, 11:55 AM , By : user2950591
Visual Studio c++ how to add version info read from .rc or .h to targetname?
Visual Studio c++ how to add version info read from .rc or .h to targetname?
To fix the issue you can do You can use Property Macros. So if you were to bring up Property Manager (View > Property Manager) and right-click a configuration and choose Add New Property Sheet... then edit that property sheet by right-clicking on it
TAG : cpp
Date : November 17 2020, 11:55 AM , By : Cluck
Generate all permutation of an array without duplicate result
Generate all permutation of an array without duplicate result
it fixes the issue This is a leetcode question permutation2. , With STL, the code may be:
TAG : cpp
Date : November 17 2020, 11:55 AM , By : Igas
DirectX 9 engine Z-buffer not working with D3DImage
DirectX 9 engine Z-buffer not working with D3DImage
fixed the issue. Will look into that further With EnableAutoDepthStencil set to TRUE, make sure CreateRenderTarget uses the same width and height as set in the presentation parameters
TAG : cpp
Date : November 17 2020, 11:55 AM , By : user2950508
opengl - possibility of a mirroring shader?
opengl - possibility of a mirroring shader?
around this issue There are no universal way to do that, in any 3D API i know of. Depending on your case there are several possible techniques with different downsides. Planar reflections: That's what you are doing already. Note that your mirror need
TAG : cpp
Date : November 17 2020, 11:55 AM , By : Mehrnaz T
error C2783: '_Ty &&std::forward(remove_reference<_Ty>::type &&) throw()' : could not deduce templ
error C2783: '_Ty &&std::forward(remove_reference<_Ty>::type &&) throw()' : could not deduce templ
I wish did fix the issue. Value categories like "lvalue" and "rvalue" are properties of expressions. Expressions that name variables are always lvalue-expressions, even if they name a variable that has the type rvalue reference to some_type.We use lv
TAG : cpp
Date : November 17 2020, 11:55 AM , By : Prashant Singh
TextOut() - "invalid null pointer"
TextOut() - "invalid null pointer"
seems to work fine You are telling TextOut that the length of the string is 500 characters when it is really only 15 characters. Since TextOut does not stop at a null terminator it will draw exactly how many characters you tell it to. The extra text,
TAG : cpp
Date : November 17 2020, 11:55 AM , By : Ben Lambert
C++- Converting very large integers expressed as strings("2134628961988274893") to binary code
C++- Converting very large integers expressed as strings("2134628961988274893") to binary code
should help you out C++ has no native support for arbitrary precision integers, however it's not difficult to implement what is needed for this specific use case. You need to: Chose a format. For example using an std::vector to store numbers in base
TAG : cpp
Date : November 17 2020, 11:55 AM , By : user2950393
3-axes quaternion rotation in OpenGL
3-axes quaternion rotation in OpenGL
Hope that helps Your code is using Euler angles (axis-aligned rotations). The wiggles and jumps are because Euler angles are a bad parameterization of the space of 3D rotations. Instead, here are two alternate approaches.Constructing a Rotation Matri
TAG : cpp
Date : November 17 2020, 11:55 AM , By : user2950392
Put numbers into different piles
Put numbers into different piles
I wish this help you You have several problems. First of all, your n variable is not initialized. That should trigger a compiler error.
TAG : cpp
Date : November 17 2020, 11:52 AM , By : bravo
what file needed to open exe in other computer mvcp100d needed
what file needed to open exe in other computer mvcp100d needed
help you fix your problem Unless you need the debug version, I would build in release mode. Not only can that be distributed, it's usually faster also. It doesn't seem to me that you are doing anything with debugging that application.
TAG : cpp
Date : November 17 2020, 11:52 AM , By : user2950286
Does set<vector<int> > have to define compare function?
Does set<vector<int> > have to define compare function?
wish helps you std::less will just invoke operator< on the T objects, unless it is specialized. std::vector has operator
TAG : cpp
Date : November 17 2020, 11:52 AM , By : YupYesYeah
CRTP - How to call the base class implemention of a method from the derived class?
CRTP - How to call the base class implemention of a method from the derived class?
Does that help The preferred method I've seen is to use this:ConsoleApplication::ShowApplicationStartupMsg();
TAG : cpp
Date : November 17 2020, 11:52 AM , By : eSleezy

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