Why we need C/C++ POINTERS
1.Data management on the free store
2.Accessing class member data and functions
3.Passing variables by reference to functions
Example:
char m[] = {1,2,3,4,5}
char *p;
p = &m[3];
Pointers on C-POINTERS
1. Variables in C are memory locations
2. If you are going to change the variable you pass the variable by using pointers otherwise pass it by value e.g
changing the variable "s" pass by pointers
char *str( int i, char *s)
{
while(i) {
s++;
i--;
}
return s;
}
void none(int i)
{
i = i + 1;
return 1;
}
3.) C++ Friend function/classes are used for accessing methods + variables between classes of different type its a communication tool
4.) static void () the function is only visible in the file in which it is defined
0 comments:
Post a Comment