Why Pointers are Dangerous in C / C++?

Veröffentlicht am: 10 März 2024
auf dem Kanal: cppjournal
547
23

Why Pointers are Dangerous in C or C++?

Pointers can bypass the security provided by the C++ programming language.
In a class, private member variables contain the confidential data and cannot be accessed by the object of class directly; only member functions can access them. But did you know that using pointers, you can access these data members even if they are private?

To do that, you just need to obtain the pointer to the object of the class. Then, cast that to a pointer of a primitive data type like an integer pointer. Now this pointer is pointing to the first private data member of the class. You can increment the pointer address and access other private data members too of this class.

Now we can even change the value of these data members of this object and make the program crash.

So, this is how pointers can break the security of your program, so use them carefully in C++.

#cplusplus #cpp #programming #coding #cplusplusprogramming #programminglife #datasecurity #security


Auf dieser Seite können Sie das Online-Video Why Pointers are Dangerous in C / C++? mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer cppjournal 10 März 2024 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 547 Mal angesehen und es wurde von 23 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!