mainprogram.cpp

来自「C++编成数据结构与程序设计方法 D.S.Malk编著」· C++ 代码 · 共 31 行

CPP
31
字号
//Chapter 13: Virtual Functions and value parameters

#include <iostream>

#include "derivedClass.h"

using namespace std;

void callPrint(baseClass p);

int main()
{
    baseClass one(5);                       //Line 1
    derivedClass two(3, 15);                //Line 2

    one.print();                            //Line 3
    two.print();                            //Line 4

    cout << "*** Calling the function "
        << "callPrint  ***" << endl;        //Line 5

    callPrint(one);                         //Line 6
    callPrint(two);                         //Line 7

    return 0;
}

void callPrint(baseClass p)  //p is a value parameter
{	
    p.print();
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?