C++ 如何调用要打印的包和派生包?

C++ 如何调用要打印的包和派生包?,c++,c++11,C++,C++11,我是一个初学者,正在编写一个程序,使用继承打印出三种类型的文件。我已经把所有的计算结果都计算出来了,但现在我只是想弄清楚如何把它们全部打印出来。如果有人能提出一些建议,既能打印出输入,又能打印出每个运输选项的成本,那就太好了 // FDHPackage: a program that creates 3 package classes that calculate the //shipping costs based on the weight and the type of package

我是一个初学者,正在编写一个程序,使用继承打印出三种类型的文件。我已经把所有的计算结果都计算出来了,但现在我只是想弄清楚如何把它们全部打印出来。如果有人能提出一些建议,既能打印出输入,又能打印出每个运输选项的成本,那就太好了

// FDHPackage: a program that creates 3 package classes that calculate the 
//shipping costs based on the weight and the type of package it is (regular,       two day, or overnight.)

#include <string> // C++ standard string class
#include "stdafx.h"
#include <iostream>
using namespace std;

class Package // Base Class
{
private: // data members 
string infoS, infoR; //Sender and Recpient information
double weight;  // in ounce 
double cost;  // per ounce 

public: //member functions 
    void setInfoS(string infoS);
    void setInfoR(string infoR);

string getInfoS()
{
    return infoS;
}
string getInfoR()
{
    return infoR;
}

double calculateCost(double weight, double costPerOunce) //function that       calculate the cost z 
    {
    double zz;  //total cost = weight*cost per ounce 
    zz = weight * costPerOunce;  //the cost zz

    cout << "The Regular Cost = " << zz << endl << endl;
    return zz;
}
   }; // end class Package

  void Package::setInfoS(string senInfo)
{
        infoS = senInfo;
 }


  void Package::setInfoR(string recInfo)
  {
        infoR = recInfo;
  }

  class TwoDayShipping : public Package // derived class
 {
public:
    double calcShippingCost(double weight, double costPerOunce, double        regularFee)
    /* function that calculate shipping cost by adding the flat fee to the weight-based cost
    calculated by base class Package’s calculateCost function*/
{
    double z; //shippingcost of Two day Package class

    z = calculateCost(weight, costPerOunce) + regularFee;
    cout << "The TwoDayPackage Cost = " << z << endl;
    return z;
}
  private:
    double regularFee;
   }; // end TwoDayShipping

 class OvernightShipping : public Package //derived class that adds the     additional fee per ounce
         {
          public:
                double calcCostOvernight(double weight, double costPerOunce, double      additionalCost)
{
    double cc; //shippingcost of overnight class
    cc = calculateCost(weight, costPerOunce) + (additionalCost * weight);

    cout << "The OvernightShipping Cost = " << cc << endl;
    return cc;
}
 private:
    double overnightCost; //per ounce 
    }; // end class OvernightShipping

 int main()
 {
    string customerInfo;
    float packageWeight;
    double costPerOunce;
    double regularFee;
    double additionalCost;

Package base;   //the object base of the package class 
TwoDayShipping twoday;  //the object twoday of the first inherited class 
OvernightShipping overnight;   //the object overnight of the second    inherited calss   

cout << " *-*-Welcome to United Postal Services-*-*" << endl << endl;
cout << "Please Enter Required Data: " << endl;;

cout << "Enter Weight" << endl;
cin >> packageWeight;
cout << endl;
cout << "Enter Cost Per Ounce" << endl;
cin >> costPerOunce;
cout << endl; 

cout << "Regular rate would cost: ";


 }
//FDHPackage:一个创建3个包类的程序,用于计算
//基于重量和包装类型的运输成本(常规、两天或隔夜)
包含//C++标准字符串类
#包括“stdafx.h”
#包括
使用名称空间std;
类包//基类
{
私人数据成员
字符串infoS,infoR;//发送方和接收方信息
双倍重量;//单位:盎司
双倍成本;//每盎司
公共成员职能
void setInfoS(字符串infoS);
void setInfoR(字符串infoR);
字符串getInfoS()
{
返回信息;
}
字符串getInfoR()
{
返回信息;
}
double calculateCost(双重重量,双重成本)//计算成本z的函数
{
双倍zz;//总成本=重量*每盎司成本
zz=重量*成本;成本zz

有什么问题吗@immibis@FrancisHeroux我相信这是“如何调用包和派生包来打印出来?”太多的代码。请提供最少的工作示例。