initial commit
This commit is contained in:
30
C++/lesson7/task1.cpp
Normal file
30
C++/lesson7/task1.cpp
Normal file
@ -0,0 +1,30 @@
|
||||
#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();
|
||||
}
|
Reference in New Issue
Block a user