+ 1

How to understand pointers and operator new?

Can you help me understand better the pointer and operator new?

23rd May 2017, 5:02 PM
Rafał
Rafał - avatar
4 odpowiedzi
+ 16
//pointers #include <iostream> using namespace std; int main() { int a = 555; //a stored in a nemory cell int * b = &a; //b's value is the address of a cout<<b<<endl; cout<<*b; //value of the adress of b return 0; }
23rd May 2017, 5:07 PM
Valen.H. ~
Valen.H. ~ - avatar
+ 20
You can use them to make functions that can call other functions based on users choice (by reference) and many other stuff.....
23rd May 2017, 8:16 PM
Valen.H. ~
Valen.H. ~ - avatar
+ 16
The "new" keyword is used to instantiate an object based on a class prototype (and not only). It then returns a pointer (in memory) targeting object created (if it's not an Array)... (not sure about the validity of this post....)
23rd May 2017, 5:10 PM
Valen.H. ~
Valen.H. ~ - avatar
0
Thank you and the pointers are used only for this?
23rd May 2017, 8:13 PM
Rafał
Rafał - avatar