Posts by Kahler • 1,000 points
24 posts
-
2
votes2
answers215
viewsA: Why can’t I pass a matrix as a parameter of a function in C?
You define MAX=10 and uses this value as the size of the secondary dimension in the argument matriz[][MAX], but its matrix has dimensions mat[3][3]. When the loop will jump line in the matrix,…
-
2
votes2
answers84
viewsA: Error of memory allocation
scanf expecting a *int to store the value of %i, you provide a *unsigned short int. It is likely that: sizeof(int) == 4 sizeof(unsigned short int) == 2 Thus, the CPU will write the result of size…
-
1
votes1
answer124
views -
2
votes1
answer318
viewsA: Can you give include in previous folder in c++?
Adding the value of the directive include in quotation marks, the file will be searched relative to the current directory. To include a header from a top/previous folder, you can use two dots:…
-
0
votes1
answer38
viewsA: How to limit a value entered/modified by the memory address?
The guy float does not have the built-in value limitation option. If you need to limit values, you need to do it while the type is still interpreted as that class you created, and then convert it to…
-
0
votes1
answer236
viewsA: Problems with C++ threads
There are many different distributions of Mingw, some do not support threads directly, and require the inclusion of platform-specific code. The page you posted contains these pieces of code,…
-
1
votes1
answer253
viewsA: Structure for search and quick insertion c++
You say that: I need to add and when there is already the element I am adding, it returns the memory position. There is a class with specific method for this, which is the std::set. The set keeps…
-
1
votes2
answers774
viewsA: How to randomize an Array in c++
Clutter a set of elements is not as common an operation as order, so it is not so recurrent subject. Here is an example of an algorithm for shuffling an array: template <typename T>…
-
2
votes1
answer100
viewsA: How to apply "goto" to quicksort? (c, c++)
The goto is an unconditional leap, can be considered the basis for all flow control. With a combination of if and goto you can create any flow control, I believe that is the purpose of the peculiar…
-
0
votes2
answers167
viewsA: How to limit a function parameter so that it is an element of a set?
You can limit the values a variable can assume through strongly typed enumerations. This is a concept introduced in C++11 to strengthen the restriction of the listed values to those belonging to the…
-
0
votes1
answer106
viewsA: Attribute of a struct receiving multiple structs
Respondent: It is possible an attribute of a struct receive several structs. The attribute you refer to, however, is only a pointer, not a container. Pointers cannot receive several structs, only…
-
5
votes3
answers171
viewsA: Is it safe to create an object pointer in the stack indirectly?
The excerpt posted is not safe: void classequalquer::metodo() { ClasseA * ponteiro = ClasseA().getThis(); //deferenciar o ponteiro aqui é comportamento indefinido //o objeto não existe mais }…
-
3
votes2
answers125
viewsA: Should I use int_least8_t or int_fast8_t?
What’s best for me to choose, int_fast8_t or int_least8_t? int_least8_t is the smallest whole type with at least 8 bits, you must choose it if you prioritize space (memory) int_fast8_tis the faster…
-
7
votes1
answer138
viewsA: Why is Offloading for the GPU a good idea?
Basically: The more processing power, the better. Simple as that. You don’t stop using the CPU to use the GPU, but uses both. A number of historical and market phenomena have contributed to an…
-
4
votes2
answers136
viewsA: How does -O3 optimization break some programs?
Two main causes that can break programs with aggressive optimization (such as -O3): compiler bugs programmer mistakes Bugs occur because compiler developers make mistakes, and the user doesn’t have…
-
12
votes2
answers1882
viewsA: How to convert a text to number?
In C++ No header <string>, in manespace std, are defined functions that convert string for numeric types. The function name is an abbreviation of sTring to int (stoi), sTring to float (stof),…
-
9
votes1
answer3505
viewsQ: Conversion to C++: What is the difference between static_cast, dynamic_cast, const_cast and reinterpret_cast?
What is the difference between casting present in the C++? There is the static_cast, dynamic_cast, const_cast and reinterpret_cast, what is the difference between these? When to use each? C++ also…
-
13
votes1
answer3505
viewsA: Conversion to C++: What is the difference between static_cast, dynamic_cast, const_cast and reinterpret_cast?
The importance of understanding the conversion of types C++ is a spoken language Strictly typed, term usually translated as heavily typed, this means that the type of variables is always right and…
-
2
votes2
answers909
viewsA: How to use Operator= to copy a pointer vector?
How to use Operator= to copy a pointer vector? The operador = is already set to vector<int*> it is obligatory to reserve memory before doing so? No. Memory allocation by std::vector is…
-
0
votes1
answer30
viewsA: How to remove the class name from the executable without losing dynamic_cast?
There is no established way to do it in Min-GW, as you want to use a language function by removing the premises on which it is based. dynamic_cast requires RTTI, which embeds class name into…
-
1
votes3
answers4203
viewsA: Generating random numbers C++
C++11 can already be considered standard, and introduced a standard library for random numbers, <random>, even if it’s not the source of your problem, I’ll introduce you. The main problem of…
-
0
votes2
answers74
viewsA: Where is the function that a decayed lambda to pointer points to stored? How is it released?
(gathering information from related questions suggested with the answer to replica of the question on the website in English, I came to the following conclusion:) When declaring a lambda, the…
-
3
votes2
answers74
viewsQ: Where is the function that a decayed lambda to pointer points to stored? How is it released?
I learned recently that I can do this: auto a = +[]{return true;}; a = +[]{return false;}; And I understood that a lambda that captures nothing can decay to a pointer for function, as confirmed by…
-
2
votes3
answers1104
views