-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path6.1
More file actions
44 lines (38 loc) · 713 Bytes
/
6.1
File metadata and controls
44 lines (38 loc) · 713 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
#include "pch.h"
#include <iostream>
#include <string>
using namespace std;
class flover
{
friend void cost(flover &);
friend void setPrice(flover &, int price);
public:
flover(string Name, int Price)
{
name = Name;
price = Price;
}
string getName() { return name; }
int getPrice() { return price; }
private:
string name;
int price;
};
void cost(flover &a)
{
cout << a.name << " cost " << endl;
}
void setPrice(flover &a, int price)
{
if (price > 0)
a.price = price;
}
int main()
{
flover rouse("Roses", 50);
cost(rouse);
cout << rouse.getName() << " : " << rouse.getPrice() << endl;
setPrice(rouse, 80);
cout << rouse.getName() << " : " << rouse.getPrice() << endl;
return 0;
}