31 lines
592 B
C++
31 lines
592 B
C++
#include <iostream>
|
|
#include <string>
|
|
|
|
struct Good {
|
|
std::string name;
|
|
unsigned cost;
|
|
unsigned amount;
|
|
|
|
Good(std::string name, unsigned cost, unsigned amount) {
|
|
this->name = name;
|
|
this->cost = cost;
|
|
this->amount = amount;
|
|
}
|
|
|
|
void information() {
|
|
std::cout << '(' << name << ',' << cost << ',' << amount
|
|
<< ")\n";
|
|
}
|
|
|
|
void changeCost(unsigned cost) {
|
|
this->cost = cost;
|
|
}
|
|
};
|
|
|
|
int main() {
|
|
Good apple("Apple", 10, 20);
|
|
apple.information();
|
|
apple.changeCost(20);
|
|
apple.information();
|
|
}
|