-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclass1.cpp
More file actions
34 lines (33 loc) · 747 Bytes
/
Copy pathclass1.cpp
File metadata and controls
34 lines (33 loc) · 747 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
//program to define class like structure
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
using namespace std;
class emp //class in cpp with access spacifiers like public ,private
{
//creating class variable private
private:
int id;
float sallary;
char name[20];
//creating class functions public
public:
void input()
{
cout<<"Enter id,name,sallary ";
cin>>id>>name>>sallary;
}
void show()
{
cout<<"id = "<<id<<endl<<"name = "<<name<<endl<<"sallary = "<<sallary<<endl;
}
};
int main(int argc, char const *argv[])
{
system("cls");
emp e1; //creating object of class emp like structure
e1.input();
e1.show();
system("pause");
return 0;
}