The program defines a structure test with two data members x and y. It also defines a member function display() to display the values of x and y. In the main() function, an object o of type test is created. The values of x and y are assigned using the dot operator .. Finally, the display() function is called on the object o, which displays the values of x and y.
#include<iostream> using namespace std; struct test { int x; //Data Member int y; void display()//Data Function { cout<<"X value is : "<<x<<endl; cout<<"Y value is : "<<y<<endl; } }; int main() { test o; o.x=10; o.y=20; o.display(); return 0; }To download raw file Click Here
X value is : 10 Y value is : 20
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions