-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy path7.cpp
More file actions
49 lines (47 loc) · 751 Bytes
/
7.cpp
File metadata and controls
49 lines (47 loc) · 751 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include<iostream>
using namespace std;
class property{
int p_id;
string p_name;
float p_price;
public:
void setdata(int a,string b,float c)
{
p_id=a;
p_name=b;
p_price=c;
}
void getdata()
{
cout<<"ID: "<<p_id<<endl<<"Name: "<<p_name<<endl<<"Price: "<<p_price;
}
};
int main()
{
property *p;
int x;
cout<<"Enter number of objects: ";
cin>>x;
p=new property [x];
for(int i=0;i<x;i++)
{
int n;
string s;
float f;
cout<<"Enter "<<i+1<<" th id: ";
cin>>n;
cout<<"Enter "<<i+1<<" th name: ";
cin>>s;
cout<<"Enter "<<i+1<<" th price: ";
cin>>f;
p[i].setdata(n,s,f);
}
for(int i=0;i<x;i++)
{
cout<<i+1<<" th entry:-"<<endl;
p[i].getdata();
cout<<endl;
}
delete [] p;
return 0;
}