Example:
In this example, we are declaring a structure named "Student" which has two private data members rNo to store roll number of the student and perc to store a percentage of the student. And, to public member functions read() to read student details (roll number and percentage) of the student and print() to print the student details (roll number and percentage).
Public member functions read() and print() are accessing private data members rNo and perc just like a class. And the public member functions are calling within the main() function using the structure variable named std.
Program:
Output