0
C++
How to delare pointer in c++
7 Réponses
+ 5
Aminu Abdulkadir
by putting * (asterisk) between type and variable identifier (name):
int *my_int;
or:
int * my_int;
or:
int* my_int;
would declare a pointer to an int ^^
+ 4
Pointers can be initialised to NULL, which is good practice, if you're not immediately assigning the address of a memory block to it.
+ 4
It depends on whether the pointer points to an integer (int*), character(char*), float(float*), double(double*) etc.
+ 3
Your thread will look better if you move the title text 'C++' into the tags, and the Description text 'How to declare pointer in C++' in the question title 👍
+ 1
however, you need to assign a valid memory address to it (another existing variable address or a dynamic allocated memory space address)
+ 1
thanks👍🙏
+ 1
main()
{
int *p;
}