MCPcopy Create free account
hub / github.com/ShiqiYu/CPP / Storage

Class Storage

week15/examples/nestedclass.cpp:3–26  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1#include <iostream>
2using namespace std;
3class Storage
4{
5public:
6 class Fruit
7 {
8 string name;
9 int weight;
10 public:
11 Fruit(string name="", int weight=0):name(name), weight(weight){}
12 string getInfo(){return name + ", weight " + to_string(weight) + "kg.";}
13 };
14private:
15 Fruit fruit;
16public:
17 Storage(Fruit f)
18 {
19 this->fruit = f;
20 }
21 void print()
22 {
23 cout << fruit.getInfo() << endl;
24 }
25
26};
27
28int main()
29{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected