+ 1
How to understand pointers and operator new?
Can you help me understand better the pointer and operator new?
4 Respostas
+ 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;
}
+ 20
You can use them to make functions that can call other functions based on users choice (by reference) and many other stuff.....
+ 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....)
0
Thank you and the pointers are used only for this?