2018년 5월 11일 금요일

[C++] Examples


#include <iostream>
#include <string>

using namespace std;

class Package {

    public:
        string _SenderName;
        int    _fee;

        Package(string SenderName, int fee) {
            _SenderName = SenderName;
            _fee = fee;
        }
};

class ExpressPackage: public Package {

    public:
        int _extraFee;
    
        ExpressPackage(string SenderName, int fee, int extraFee)
            : Package(SenderName, fee)
        {
            _extraFee = extraFee;
        }
};

int main(int argc, const char * argv[]) {
    // insert code here...
    
    ExpressPackage DHL("Tom", 5, 10);
    
    cout << DHL._SenderName << endl;
    cout << DHL._fee << endl;
    cout << DHL._extraFee << endl;
    
    return 0;
}