⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pr06030.cpp

📁 c++编程宝典源码及Quincy99编译器 是《标准C++编程宝典》电子工业出版社的光盘
💻 CPP
字号:
////////////////////////////////////////
// File Name: pr06030.cpp
////////////////////////////////////////
#include <iostream>

// Date structure.
struct Date
{
    int month, day, year;
};

// Function prototypes.
void display(const Date&, const char*);
void swapper(Date&, Date&);

////////////////////////////////////////
// The main() function.
////////////////////////////////////////
int main()
{
    // define two dates.
    static Date now  = {2,23,90};
    static Date then = {9,10,60};

    // Display the dates.
    display(now, "Now:  ");
    display(then, "Then: ");

    // Swap the dates and redisplay them.
    swapper(now, then);
    display(now, "Now:  ");
    display(then, "Then: ");

    return 0;
}

////////////////////////////////////////
// Swap the caller's dates.
////////////////////////////////////////
void swapper(Date& dt1, Date& dt2)
{
    Date save;
    save = dt1;
    dt1 = dt2;
    dt2 = save;
}

////////////////////////////////////////
// Display a Date object.
////////////////////////////////////////
void display(const Date& dt, const char* ttl)
{
    std::cout << ttl;
    std::cout << dt.month << '/'
              << dt.day   << '/'
              << dt.year  << std::endl;
}

⌨️ 快捷键说明

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