1
2struct Rectangle {
3 int width; // member variable
4 int height; // member variable
5
6 // C++ constructors
7 Rectangle()
8 {
9 width = 1;
10 height = 1;
11 }
12
13 Rectangle( int width_ )
14 {
15 width = width_;
16 height = width_ ;
17 }
18
19 Rectangle( int width_ , int height_ )
20 {
21 width = width_;
22 height = height_;
23 }
24 // ...
25};
26
27
1#include<iostream>
2#include<string>
3using namespace std;
4struct student
5{
6 char name [20];
7int age;
8float marks;
9};
10int main()
11{
12student s;
13cout<<"enter student name : "<<endl;
14cin>>s.name;
15cout<<"enter age : "<<endl;
16cin>>s.age;
17cout<<"enter marks : "<<endl;
18cin>>s.marks;
19cout<<"***********************"<<endl;
20cout<<"name : "<<s.name<<endl;
21cout<<"age : "<<s.age<<endl;
22cout<<"marks : "<<s.marks<<endl;
23return 0;
24}