Posts by cYeR • 1,041 points
34 posts
-
-1
votes2
answers58
viewsQ: How to return different structures in a function with a value defined in Runtime?
Hello, I am working on a project for Windows that has a structure (of Windows itself) that changes according to the architecture of the system (x86/x64), how to return the correct structure for a…
-
3
votes1
answer149
viewsQ: What is the difference between memmove and memcpy?
What is the difference between the function memmove() and memcpy()?
-
2
votes2
answers55
viewsQ: Can you add the keyword "noexcept" in get/set methods?
Is there any problem in adding to keyword noexcept in methods getters/setters of a class that only returns or changes values of simple variables (bool, int, float, double, etc..)?…
-
3
votes1
answer46
views -
0
votes1
answer68
viewsQ: How to use a template as a type in a map?
Is there any way to use template as type in a map in C++17? template<typename T> std::map<std::string, T/* tipo desconhecido, pode ser qualquer tipo */> map_exemplo;…
-
1
votes1
answer133
views -
2
votes1
answer75
views -
0
votes1
answer322
viewsQ: How to test the execution time of a code in Visual Studio 2017?
I’m trying to test the execution time of a code, but I’m always getting incorrect values, the first test will always be the one with the worst time. And most of the time the second test is always 0.…
-
0
votes1
answer42
viewsQ: How much can the access cost of an unodered_map hinder the performance of a game?
The cost of access to unordered_map can cause FPS to drop in a game if it is accessed thousands of times per second? class var { public: template < typename t = double > static inline auto…
-
2
votes1
answer73
views -
1
votes1
answer38
viewsQ: How to limit a value entered/modified by the memory address?
To limit a value that has been entered/changed by the memory address? PS: I can not limit by function, this function is just an example function showing the problem, I will need to pass this object…
-
5
votes2
answers134
viewsQ: What is the problem of returning a local variable?
What can happen if I return a local variable? I read on the internet that it is not a good idea to return a local variable. Maybe why the variable when exiting the function is deleted? Example:…
-
5
votes3
answers337
viewsQ: What’s wrong with allocating memory with new and then not erasing?
What can happen if I use the new to allocate memory and then don’t release it? And when it is in the situation below, that I can not erase the allocated memory, because I need to return, what I do?…
-
7
votes2
answers1064
viewsQ: Lambda functions in C++, when to use and what are the advantages?
When choosing to use a lambda function or a normal function, and what is the advantage of using a lambda function compared to a normal function? There is the call price of a function in a lambda…
-
6
votes1
answer56
viewsQ: When to choose between using a string wide or not?
When using a string wide (std::wstring) or a string normal (std::string)?
-
2
votes1
answer194
viewsQ: Difference between Std::map, Std::unordered_map, Std::flat_map, and which one to choose?
What is the difference between library functions map, unordered_map, flat_map, and which one to use, for example in terms of performance?
-
2
votes2
answers1067
views -
4
votes3
answers138
viewsQ: In structures (struct) is it necessary to use getters and setters or only in classes (class)?
It is necessary to use setters and getters in structures to maintain good practice or is needed only in classes?
-
2
votes1
answer221
viewsQ: How to use a class array as a pointer?
How do I use a class array as a pointer? I tried several ways, but C++ didn’t let you compile by generating errors. An example of class(It’s just one example, the class I need to use is thousands of…
-
13
votes4
answers4494
views -
1
votes2
answers1792
viewsA: How to turn this C++ code into C?
Just swap the Cin for scanf, and the Cout for printf and remove using namespace and switch the library to stdio. h #include <stdio.h> // printf e scanf int main() { int n, i, n1, c = 0, c1,…
-
4
votes1
answer350
viewsQ: How to initialize an array in this constructor?
I’m trying to initialize a array with 0, however the compiler is generating error, I know I can initialize as well: Constructor() : Value1(0), Value2(0), Initialized(false), vSh(false) { Name[100] =…
-
1
votes0
answers85
viewsQ: How to leave a function of an object superimposed on that of another object?
I’m having problems with my code for a D3D9 function, the "Create" function is always overlapped, need another function of the object (Draw) is overlapping the others. class cDrawItem { private:…
-
1
votes1
answer101
viewsQ: What is the point of calling conventions and which one to use?
What is the purpose of calling conventions __fastcall, __stdcall, __thiscall, __cdecl, __fastcall and how to know which one to use? For example, in some function that needs to be called faster (I…
-
1
votes0
answers569
viewsQ: Why use gets and sets in classes?
What is the reason and when to actually use gets and sets instead of a publish variable in classes? They say it is a bad practice to use and modify a variable as public, why? Example 1: class Teste…
-
1
votes2
answers371
viewsQ: What’s the difference between initializing a variable in these constructs? And how do you set a constructor to default?
Is there a difference when initializing a variable in any of these constructor forms? And how do I default a constructor (default) in a class that has more than one constructor? Constructor 1: class…
-
10
votes3
answers540
viewsQ: What kind of smart pointer to choose?
How to know what kind of smart pointer to use? And what’s the difference between them? Example: std::unique_ptr<MinhaClasse> mClasse(new MinhaClasse) std::shared_ptr<MinhaClasse>…
-
0
votes1
answer815
viewsQ: How do I create a char variable with an indeterminate size
How do I create a char* variable (to store a name) with an indeterminate size? Example: char nome[30] = { 0 } // 30 é o valor máximo e no caso se a pessoa tiver um nome grande? que ultrapasse 30?…
-
1
votes0
answers55
viewsQ: Problem with my horizontal bar
I am having problems with my horizontal bar, the problem is that it is not increasing the value of the variable "Ivar" 1 in 1, is increasing 5 in 5 or even more dependent on how much I pass the…
-
1
votes4
answers106
viewsQ: What’s wrong with my class function to diminish the value?
I’m developing a class to better manage my items in a more organized way. When the value of the variable is less than the minimum value was to go to the maximum value, however, in practice this is…
-
3
votes2
answers307
viewsQ: C Cast vs C++ Cast
What’s the difference between using the C cast: float t = 5.0f; int v = (int)t; For the cast of C++: float t = 5.0f; int v = static_cast<int>(t);…
-
2
votes1
answer63
viewsQ: Difference of calling a function in Dllmain by Createthread or calling directly
What is the difference of calling a function in the following ways: The first way creating a thread. Example: DWORD WINAPI Metodo1(LPVOID) { // Meu código aqui... return NULL; } int WINAPI…
-
3
votes1
answer112
viewsQ: About __forceinline and __inline
What is the difference between using __forceinline or __inline? And you can use __forceinline or __inline large-scale? Example: __forceinline void funcao1(void) { cout << "Funcao 1" <<…
-
2
votes2
answers248
viewsQ: What is the best method to access a class member?
What is the best method to access a class member for speed and organization? class cMinhaClasse { public: void Funcao(int r); }; int main() { // Método 1 - Acessando classe por ponteiro cMinhaClasse…