logo
down
shadow

CPP QUESTIONS

Single protected member variable in base class VS Multiple private member variable in derived class
Single protected member variable in base class VS Multiple private member variable in derived class
I think the issue was by ths following , The difference is that by having a single member in the base class you can provide default implementation or even base class member functions that manipulate the image.The dark side is however that you're plac
TAG : cpp
Date : November 11 2020, 09:01 AM , By : Senti Eti
Defining 2D arrays in C++
Defining 2D arrays in C++
I hope this helps you . , Yes! It is a valid intialization in c++.
TAG : cpp
Date : November 11 2020, 09:01 AM , By : kirilla
How can I "prepare " char arrays to boost::asio::streambuf::mutable_buffers_type buffers?
How can I "prepare " char arrays to boost::asio::streambuf::mutable_buffers_type buffers?
it helps some times ostream Simplest way is to use the streambuf as intended... as a streambuf:
TAG : cpp
Date : November 11 2020, 09:01 AM , By : Priti kanitkar
Why can't the program output immidiately?
Why can't the program output immidiately?
Hope that helps You can use header file string instead, which provides more flexibility like below:
TAG : cpp
Date : November 11 2020, 09:01 AM , By : Cornel Boppart
Lua 5.3 in Visual Studio 2015
Lua 5.3 in Visual Studio 2015
help you fix your problem You're probably running into the C-runtime changes introduced in VS2015: The Great C Runtime Refactoring.You can add the following library to supply those definitions in the Additional Dependencies in the Project Settings ->
TAG : cpp
Date : November 11 2020, 09:01 AM , By : rois
Issues figuring out readin/writeout for a bank program
Issues figuring out readin/writeout for a bank program
Does that help IN the newAccount function you will have to store the username and password with the following lines of code.
TAG : cpp
Date : November 11 2020, 09:01 AM , By : Muayad Qanadilo
cpp string find() doesnt work as expected - returns big junk values
cpp string find() doesnt work as expected - returns big junk values
I hope this helps you . What it return is size_t of npos of your string because it can't find your char or text. you can do this instead:
TAG : cpp
Date : November 11 2020, 09:01 AM , By : borun
sf::Texture applied in a wrong way
sf::Texture applied in a wrong way
With these it helps It looks like the texture coordinates might be outside of the texture. If the pointPosition function refers to the p0, p1, p2, and p3 points in side.cpp, then it also looks like you're using those points as texture coordinates.
TAG : cpp
Date : November 11 2020, 09:01 AM , By : Muhammad Waqar Arsha
C++ Heap corruption after simple action
C++ Heap corruption after simple action
Any of those help Your code modified the pointer "matrix" before you free it, which I believe is an undefined behavior.No offense, but I suggest you get a good book about c++. "malloc" is not the preferred way for dynamic memory allocation in c++.
TAG : cpp
Date : November 11 2020, 09:01 AM , By : Wendy Aartsen
How to fill the data or access a 3-dimensional vector in C++
How to fill the data or access a 3-dimensional vector in C++
This might help you Instead of coping with std vector ; IMHO you should use a data structure designed for multi dimensions. A good example presented in cppconf2015: https://youtu.be/CPPX4kwqh80 ; you can find the git hub link in video's description.
TAG : cpp
Date : November 11 2020, 09:01 AM , By : Karthigeyan Jk
How to use shared_ptr in a decorator pattern implementation correctly?
How to use shared_ptr in a decorator pattern implementation correctly?
I wish did fix the issue. The problem doesn't seem to be the std::shared_ptr use in your classes: that seems to be semantically correct (it is too much code to review in detail, though). Instead, I think your main() is wrong: you try to determine mem
TAG : cpp
Date : November 11 2020, 09:01 AM , By : espressodrunker
Trying to understand simple big number calculations
Trying to understand simple big number calculations
may help you . addition and substractions are pretty straightforwardYou need to inspect signs and magnitudes of operands and if needed convert the operation to/from +/-. Typical C++ implementation of mine for this is like this:
TAG : cpp
Date : November 10 2020, 09:01 AM , By : juanjoharo
C plus plus wont loop
C plus plus wont loop
Does that help Why wont the code ask the user again when I try running it if the answer is not y or n?
TAG : cpp
Date : November 10 2020, 09:01 AM , By : praneeth
Does a pointer point to something when initialized with NULL?
Does a pointer point to something when initialized with NULL?
This might help you You are confusing pointers with the things pointed to.In this case, tree.left can point to another TreeNode, but it cannot be another TreeNode. And immediately after the initialization of tree, it will be NULL.
TAG : cpp
Date : November 10 2020, 09:01 AM , By : Abhilasha Patil
Extracting timestamps from an XML file
Extracting timestamps from an XML file
wish of those help As Anon Mail has suggested If you are trying to parse the entire .xml file with different parameters I would suggest using an xml library such as rapidxml or tinyxml. However for the purpose of the question I have included a versio
TAG : cpp
Date : November 10 2020, 09:01 AM , By : seoadr
Convert Glut mouse coordinates to opengl
Convert Glut mouse coordinates to opengl
hop of those help? I have a screen size of 1000x1000 px and I am trying to attain the opengl coordinates. I understand the OpenGL coordinate system is as follows:
TAG : cpp
Date : November 10 2020, 09:01 AM , By : Shivaprasad Rao
Using std::vector with std::thread
Using std::vector with std::thread
it should still fix some issue I have a program where I go through each class in a std::vector , do some operations on it and write it to a new std::vector , Model your operation after std::copy.Something along the line
TAG : cpp
Date : November 10 2020, 09:01 AM , By : りょう麻野
Array Based Deques: Why is AddFront/RemoveFront O(1)?
Array Based Deques: Why is AddFront/RemoveFront O(1)?
I wish this help you With an array based deque why is add and remove from the front ammortized O(1)? It would make sense to me that it would always be O(n) because either operation would mean that the current values of the array would need to be "mov
TAG : cpp
Date : November 09 2020, 09:01 AM , By : blue
How to distinguish objects of derived classes C++
How to distinguish objects of derived classes C++
seems to work fine Your vector of A is not capable of holding Bs or Cs, because it stores A by value, resulting in object slicing when B or C is stored. In particular, this means that when you store B, only aa gets stored; bb gets sliced away.In orde
TAG : cpp
Date : November 09 2020, 09:01 AM , By : Domyoung Lee
Passing 2D array as an argument to a function which takes 1D array
Passing 2D array as an argument to a function which takes 1D array
hop of those help? I am a beginner at C++, but as far as I know, it would not be possible to pass a 2-d array to your function bestCard(), assuming that you have not overloaded your bestCard() function to take different types of parameters.Based on t
TAG : cpp
Date : November 09 2020, 09:01 AM , By : Mahammad Ali
Object array parameter--error: field ‘letters’ has incomplete type
Object array parameter--error: field ‘letters’ has incomplete type
I wish this help you The compiler won't accept a struct containing instances of itself if they're not pointers. The error you're getting is because the declaration is recursively using itself. (Trie contains an array of Trie, where each element conta
TAG : cpp
Date : November 09 2020, 09:01 AM , By : Lucas Brinkers
ofstream does not create file when running with CLion using CMake
ofstream does not create file when running with CLion using CMake
wish help you to fix your issue The file may be created into another directory (the working directory).You can find that location (and change it if needed) as indicated here: How do I change the working directory for my program
TAG : cpp
Date : November 09 2020, 09:01 AM , By : Kaushik Alakal Praka
Can passing an array of pointers to a function as an 'int' parameter convert the addresses to integers?
Can passing an array of pointers to a function as an 'int' parameter convert the addresses to integers?
help you fix your problem If you dereference int*[] (or int**), you get an int*. If you dereference an int*, you get an int. This is exactly what you are doing, and why you end up with an int at the end.
TAG : cpp
Date : November 09 2020, 09:01 AM , By : Junaid Ur Rehman
QTextEdit::setPalette is not updating the text color
QTextEdit::setPalette is not updating the text color
I think the issue was by ths following , I have only QTextEdit and QPushbutton on the form and it is working fine for me. If you won't find the error then please provide you full code.
TAG : cpp
Date : November 09 2020, 09:01 AM , By : Jolka Joke
how is this lambda with an empty capture list able to refer to reaching-scope name?
how is this lambda with an empty capture list able to refer to reaching-scope name?
I wish this helpful for you You have the right quote. A variable needs to be captured if it is odr-used. ODR-use means basically that the variable is used in a context where it needs a definition. So either its address is taken, or a reference is tak
TAG : cpp
Date : November 09 2020, 09:01 AM , By : teng liu
Making following C++ code concise and efficient
Making following C++ code concise and efficient
Any of those help I have an array of 52 elements, and each 13 elements need to have value from 1-13 , You're right, you could do way better:
TAG : cpp
Date : November 09 2020, 09:01 AM , By : Ahmed
Convert a single character to lowercase in C++ - tolower is returning an integer
Convert a single character to lowercase in C++ - tolower is returning an integer
will be helpful for those in need That's because there are two different tolower functions. The one that you're using is this one, which returns an int. That's why it's printing 116. That's the ASCII value of 't'. If you want to print a char, you can
TAG : cpp
Date : November 09 2020, 09:01 AM , By : TedF
Does access by reference violate strict aliasing rule?
Does access by reference violate strict aliasing rule?
To fix the issue you can do Strict aliasing rules mean that you should not dereference pointers of different types pointing to the same memory location.Since in your posted code you never dereference, it's not possible to tell if this violates the ru
TAG : cpp
Date : November 09 2020, 09:01 AM , By : Alexandru Cotioras
C++ Precompiled Header Disabled
C++ Precompiled Header Disabled
it helps some times Ok. Hans Passant found out what was happening:The build configuration that I used to build it still had precompiled headers enabled.
TAG : cpp
Date : November 09 2020, 08:00 AM , By : Deepak
Storing enum values from another namespace in an array
Storing enum values from another namespace in an array
With these it helps Enums are basically a way to define integer constants; they don't have some address associated so that you can have a pointer to them in the traditional sense. What you want to do is possible to some extent (check my full example
TAG : cpp
Date : November 09 2020, 08:00 AM , By : Muhammad Irfan
Why I don't get the context of the virtual printer?
Why I don't get the context of the virtual printer?
hope this fix your issue Don't do error check on the result of the first EnumPrinters (Petzold doesn't do it either)Note also, the amount of required memory could be several hundred bytes for 1 printer. But PRINTER_INFO_5 pinfo5[1]; may allocate less
TAG : cpp
Date : November 09 2020, 08:00 AM , By : Janani
Graph outdegree help C++
Graph outdegree help C++
Any of those help The problem is that you have never declared the variable vertexName. It should probably be either your class variable or an argument to the method. I.e,
TAG : cpp
Date : November 09 2020, 08:00 AM , By : anuja saxena
Explanation of "int factorial = 1" in this for loop
Explanation of "int factorial = 1" in this for loop
wish helps you I have this code which intends to explain how "for loops" work.
TAG : cpp
Date : November 09 2020, 08:00 AM , By : Redman45
std::unique_ptr attempting to reference a deleted function
std::unique_ptr attempting to reference a deleted function
it helps some times A std::unique_ptr cannot be copied. Even if the managed object could (but yours can't).You have a couple of alternatives here (all with different effects):
TAG : cpp
Date : November 09 2020, 08:00 AM , By : ErenO
opengl 4.1 alternatives to store images in the GPU for later access, processing and rendering?
opengl 4.1 alternatives to store images in the GPU for later access, processing and rendering?
I hope this helps . The GL_MAX_TEXTURE_IMAGE_UNITS is the maximum of different texture units which can be in use at once during a single draw call. This means that the GPU (or more precisely, your fragment shader - there are separate limits for the o
TAG : cpp
Date : November 09 2020, 08:00 AM , By : Patel Ketul
C++ global scope class
C++ global scope class
around this issue I'm learning c++ and I make a program to show input numbers using classes. I used constructors to initialize the x and y. The program works fine but I wanted to use the global scope to show the variables instead of a function. The c
TAG : cpp
Date : November 09 2020, 08:00 AM , By : Gsd
C++ compiler error regarding initialization of a non-const reference of type 'std::ostream&' from a temporary of typ
C++ compiler error regarding initialization of a non-const reference of type 'std::ostream&' from a temporary of typ
I wish this help you I've been attempting to create a program that implements a real-time scheduling algorithm for a defined set of processes. While compiling with g++ I get an error, which states: , change
TAG : cpp
Date : November 09 2020, 08:00 AM , By : CKeppler
C++ signed and unsigned int vs long long speed
C++ signed and unsigned int vs long long speed
it helps some times Today, I noticed that the speed of several simple bitwise and arithmetic operations differs significantly between int, unsigned, long long and unsigned long long on my 64-bit pc. , The slowest operation in your code is
TAG : cpp
Date : November 08 2020, 09:00 AM , By : Xiquinho Silva
Cannot allocate memory dynamically in loop (a function eats all the memory)
Cannot allocate memory dynamically in loop (a function eats all the memory)
it helps some times Try lowering 2048 to a more reasonable number. As it is you are trying to allocate millions of floats in large blocks, which doesn't seem reasonable. (It might actually be 10s of millions)Even at just 128, you are trying to alloca
TAG : cpp
Date : November 08 2020, 09:00 AM , By : Shashank Bellary
How to watch any window movements with xlib?
How to watch any window movements with xlib?
should help you out How do I track move event for all the windows? Like if user moves window "Pluma" my daemon would receive window name and new coordinates. , You need t select SubstructureNotify mask on the root window first:
TAG : cpp
Date : November 08 2020, 09:00 AM , By : Ernas Moethar
Division by integers guaranteed to yield same floating point number?
Division by integers guaranteed to yield same floating point number?
will help you As long as k*x and k*y operations are exact (the result fits in a floating point), then IEEE754 standard guarantees that you'll get the nearest floating point to the exact division result.Obviously, since (k*x)/(k*y)=(x/y) in exact math
TAG : cpp
Date : November 08 2020, 09:00 AM , By : hridesh chaudhary
Create a vector of object from another vector of string
Create a vector of object from another vector of string
it fixes the issue Lambda function Still technically a loop, but multiple times uglier:
TAG : cpp
Date : November 08 2020, 09:00 AM , By : Jahanzaib Ahmed Jam
Enter character instead int C++
Enter character instead int C++
seems to work fine When you try to read an integer, and you give something that's not an integer as input, there are two things happening: The first is that the stream gets its failbit set, the second things that happens is that the input is not extr
TAG : cpp
Date : November 08 2020, 09:00 AM , By : Martin Ibarra
C++ Bool Returning Hexadecimal Int?
C++ Bool Returning Hexadecimal Int?
this will help In C++ zero is considered false, and everything non-zero is true. In your case there's an implicit conversion from the integer to a boolean value.
TAG : cpp
Date : November 08 2020, 09:00 AM , By : rey
C++ Constructor with fixed length array as parameter
C++ Constructor with fixed length array as parameter
it should still fix some issue I'm sure this is a duplicate but everything I've seen has explained how to dynamically allocate memory for an array. I have a fixed length of an array and I just want to put it in a wrapper struct for ease of reference.
TAG : cpp
Date : November 08 2020, 09:00 AM , By : Devin
Delete object from array in c++
Delete object from array in c++
it should still fix some issue delete fruits[0] will delete that one object for you. delete[] instead serves to delete all non-null elements of that array, but fruits[0] is not an array of objects.
TAG : cpp
Date : November 08 2020, 09:00 AM , By : Nanditha
how to convert abstract class to normal class without overload pure virtual function?
how to convert abstract class to normal class without overload pure virtual function?
hope this fix your issue Inheritance represents a "kind-of" relationship. Since C does not have a getN() method, it cannot be a "kind of" A since anyone holding a reference to an A has the right to expect getN() to be present.
TAG : cpp
Date : November 08 2020, 09:00 AM , By : mehak
Does the compiler eliminate unnecessary `dynamic_cast`s?
Does the compiler eliminate unnecessary `dynamic_cast`s?
With these it helps Yes, if the compiler can determine that the cast will always succeed, then it will omit the runtime check. And in your case, since the cast is trivial it cannot fail.If the types are the same no conversion is done at all. In C++ s
TAG : cpp
Date : November 08 2020, 09:00 AM , By : unoo
C++: Why does a functor for set order which returns false only lets one element be added to the set?
C++: Why does a functor for set order which returns false only lets one element be added to the set?
like below fixes the issue In this case, std::set uses !(a < b) !(b < a) to determine equality of two elements: a and b.!(false) !(false) will be yielding true everytime, when checking for duplicates, thus not allowing std::set to contain more than
TAG : cpp
Date : November 08 2020, 09:00 AM , By : Kristine Morinaka
Proper way to identify type of derived class(type entity VS dynamic_case)
Proper way to identify type of derived class(type entity VS dynamic_case)
This might help you There is also solution 3 with a virtual getType (and no type field stored in the base).
TAG : cpp
Date : November 08 2020, 09:00 AM , By : Arshya Sharifian
Is dynamic memory comparable to global variables?
Is dynamic memory comparable to global variables?
it fixes the issue new is not like global variable. In C++, Global Variable (assuming you not talking about global pointer) is allocated before your application entry point which is "main" is called and deallocate when your application is shutdown.ne
TAG : cpp
Date : November 08 2020, 09:00 AM , By : Wenugroho
MFC - Minimize main MDI window only
MFC - Minimize main MDI window only
wish help you to fix your issue When window is minimized, it takes down with it all of its child and owned windows. This code creates a regular (not topmost) window which is not hidden when the main frame is minimized:
TAG : cpp
Date : November 08 2020, 09:00 AM , By : Stanley Lio
Cannot find .a static library files after building boost with macports, I only have dylib
Cannot find .a static library files after building boost with macports, I only have dylib
it helps some times There is a MacPorts variant "no_static" that is enabled by default. To build the static library for boost, use (assuming you still require a universal binary)
TAG : cpp
Date : November 08 2020, 09:00 AM , By : Pooja
passing array from one function to the other
passing array from one function to the other
should help you out Two issues:1) The array is not initialized to contain 55 zeros, but only 1, remaining 54 elements are going to be some older memory content:
TAG : cpp
Date : November 08 2020, 09:00 AM , By : Phương Mai
Parsing XML file with RapidXML - only parsing first line of files
Parsing XML file with RapidXML - only parsing first line of files
Does that help You're confusing XML attributes and elements. Attributes would look like this:
TAG : cpp
Date : November 08 2020, 09:00 AM , By : seg
The lifetime of a temporary to which several references are bound in C++
The lifetime of a temporary to which several references are bound in C++
it helps some times This is a defect in that section that I reported as http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html1299 .The proposed resolution is to add a term "temporary expressions". Life-time extension only happens for objects re
TAG : cpp
Date : November 07 2020, 01:43 PM , By : Paulo Ricardo
Memory hack to transpose matrix corrupts stack, C++
Memory hack to transpose matrix corrupts stack, C++
With these it helps Your subscripts (or loop limits) were backwards where you initialized the matrices.You have
TAG : cpp
Date : November 07 2020, 01:43 PM , By : flannerc
clang vs gcc run-time difference: c++ class template built w clang crashes w/o copy constructor, built w gcc crashes wit
clang vs gcc run-time difference: c++ class template built w clang crashes w/o copy constructor, built w gcc crashes wit
hop of those help? Would does the following code crash during run-time when built with clang (but not gcc) unless I include a copy constructor for the TableTypeCarrier template class? If I include that copy constructor why do I experience the same ru
TAG : cpp
Date : November 07 2020, 01:43 PM , By : Mary
how to get property create in derived class using a pointer to based class c++
how to get property create in derived class using a pointer to based class c++
Any of those help You can use a pure virtual function declaration in the base and then you don't have to provide a body for the function, though you still can.
TAG : cpp
Date : November 07 2020, 01:43 PM , By : Daedalus
Wrong answer in UVa online judge
Wrong answer in UVa online judge
Hope this helps You have not read the complete question.Correct solution is as follows:
TAG : cpp
Date : November 07 2020, 01:43 PM , By : Tommaso

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