Answers for "declaring a pointer in a class c++"

C++
2

pointer c++

int myvar = 6;
int pointer = &myvar; // adress of myvar
int value = *pointer; // the value the pointer points to: 6
Posted by: Guest on September-12-2021
1

pointers in c++

void simple_pointer_examples() {
    int   a;  // a can contain an integer
	int*  x;  // x can contain the memory address of an integer. 
 	char* y;  // y can contain the memory address of a char. 
 	Foo*  z;  // z can contain the memory address of a Foo object.  
 
    a = 10;
    x = &a;   // '&a' extracts address of a 
  
    std::cout <<  x << std::endl; // memory address of a => 0x7ffe9e25bffc
    std::cout << *x << std::endl; //          value of a => 10
}
Posted by: Guest on July-15-2021
2

pointer in c++

// Variable is used to store value
int a = 5;
cout << a; //output is 5

// Pointer is used to store address of variable
int a = 5;
int *ab;
ab = &a; //& is used get address of the variable
cout << ab; // Output is address of variable
Posted by: Guest on May-27-2021

Browse Popular Code Answers by Language