Posts by snoopy • 170 points
6 posts
-
0
votes1
answer62
viewsA: How to pass structures to templates class functions
The syntax of your second code is completely wrong. template <typename T> class test{ public: struct st1{ T a, b, c; }; struct st2{ T d, e, f; }; T foo1(st1 *st); st1 *foo2(); st1 *foo3(st2…
-
1
votes2
answers173
viewsA: Independent member function in C++
Logically not! You created a function to do something you could have done outside of it (which was to use a loop for) Better would have been: int main() { pessoa pessoas[TAMPESSOAS];//Declaração de…
-
0
votes1
answer87
viewsA: Define an overloaded + Operator C++
Written code is hard to understand but, will That’s what you’re trying to do? Test Test::operator+ (Test obj) const { Test newObj; newObj.mem = obj.mem; return newObj; }…
-
0
votes2
answers198
viewsA: Pointer changes the value within function in C++
You are putting the result of the value of your operations into num1. What you are doing is similar to: int num1 = 0; int num2 = 5; num1 += num2; Now the value of num1 is the result of the…
-
1
votes1
answer253
viewsA: Pass a struct as parameter
No object has been created and you are modifying the members of the struct by a pointer that points to nothing. This is undefined behavior. The mistake is in: LPWFSPTRRETRACTBINS RetractBins;…
-
2
votes1
answer663
viewsA: Can you capture events like this when pressing a C++ key? [Codeblocks]
Using only windows you can use the function Getasynckeystate(), that determina se uma tecla está apertada ou desapertada no momento em que a função é executada Implementing in your code would look…