Delete 2D array C++

delete [] *M; is the same as delete [] M[0], so it is not equivalent to deleting all M[i] in a loop because only the first one would be deleted. The loop is the correct way to avoid memory leaks. Or better, use std::vector instead of manual allocations and you won’t need to worry about deleting pointers.

Sorting Linked List C++ with pointers

I have been struggling for hours on end with this problem. My goal is to sort a linked list using only pointers (I cannot place linked list into vec or array and then sort). I am given the pointer to the head node of the list. The only methods i can call on the pointers … Read more

How to shuffle a std::vector?

From C++11 onwards, you should prefer: Live example on Coliru Make sure to reuse the same instance of rng throughout multiple calls to std::shuffle if you intend to generate different permutations every time! Moreover, if you want your program to create different sequences of shuffles each time it is run, you can seed the constructor of the random engine … Read more

non-standard syntax; use ‘&’ to create a pointer to member

well… you forgot the (). also, in the C++ world, I would advise against writing for (int… , prefer auto or size_t instead of int. comparing signed and unsigned values can lead to errors. PS. it is extremly not common to name entities in your program in a language which is not english. also, you are mixing underscore-convention with lower camel case-convention. I’d … Read more

C++ wait for user input

Several ways to do so, here are some possible one-line approaches: Use getch() (need #include <conio.h>). Use getchar() (expected for Enter, need #include <iostream>). Use cin.get() (expected for Enter, need #include <iostream>). Use system(“pause”) (need #include <iostream>, Windows only).PS: This method will also print Press any key to continue . . . on the screen. (seems perfect choice for you :)) Edit: As discussed here, There is no completely portable solution for this. Question … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)