Answers for "pointers to structure c++"

C++
1

how to use pointer to struct c++

typedef struct{
    int vin;
    char* make;
    char* model;
    int year;
    double fee;
}car;

car TempCar;
tempCar->vin = 1234;  // metodo 1
(*tempCar).make = "GM"; // metodo 2
tempCar->year = 1999;
tempCar->fee = 20.5;
Posted by: Guest on April-10-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

Browse Popular Code Answers by Language