|
|
|
|
|
by maranas
5474 days ago
|
|
I agree with you for the most part. C/C++ lets you do what you want, presumably because you know what you're doing. But I don't agree that pointers are evil, and should be avoided. If you want to do any practical programming with C/C++ at all, you have to learn how to dynamically allocate memory and use pointers. Generally, pointers work as advertised. It's the cases where they work when they shouldn't that is the problem. In these cases a compiler usually warns you, so you are still covered. So in C/C++, just because it works, doesn't mean your code is right. |
|
No one is saying that at all. Pointers aren't evil, but they are dangerous.
Perhaps a better analogy is a sharp chef's knife. In the right hands it's an effective and efficient tool that lets you do things quicker and just as safely as any other tool.
In the wrong hands it is dangerous to the person using it and to those around them.
There are numerous other examples: welding torches, motorbikes, explosives etc etc.