Key Note: 1 Struct is an object , but array is not; typedef
allows you to create an alias for a data type. The identifiers like
typedef provides a synonym for an existing data type than
creating new data type.
---------------typedef and struct------------------------
typedef struct Emp
{
string name; string sal; int id;
} pEmp;
------- declaring an array of structures -------------
- pEmp emprec[3];
- pEmp emprec[3]={ {"A","45k", 10},
{"B","55k", 11},
{"C","65k", 12}
};
------------------Array element indexed in sturcture--------------------------------------
- emprec[i] : shows an indexed struct element used like an
array.
- emp_record(&emprec[i]); passing address of structure
element with an index
- cin>>ptr1->name; assigning the address of a structure
element with (->) pointer structure operator