C++ Structures
C++ Structures
C++ Structures
struct Person
{
char name[50];
int age;
float salary;
};
▪ The rules are the same than for fundamental data types,
For example:
struct products {
char name [35];
float price;
} ;
products a_product;
// a_product is an object of struct type products
products* p_product;
// p_product is a pointer to point to objects of products
Computer Programming 3/20/2021 8
#include <iostream> cout << "Enter feet: ";
using namespace std; cin >> (*ptr).feet;
cout << "Enter inch: ";
struct Distance { cin >> (*ptr).inch;
int feet;
float inch; cout << "Displaying
}; information." << endl;
cout << "Distance = "
int main() << (*ptr).feet
{ << " feet "
Distance *ptr, d; << (*ptr).inch
<< " inches" << endl;
ptr = &d;
return 0;
}