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

📄 ex6_01.cpp

📁 Beginning Visual C++ 6源码。Wrox。
💻 CPP
字号:
// EX6_01.CPP
// Exercising pointers to functions
#include <iostream>
using namespace std;

long sum(long a, long b);            // Function prototype
long product(long a, long b);        // Function prototype

int main(void)
{
   long (*pdo_it)(long, long);       // Pointer to function declaration

   pdo_it = product;
   cout << endl
        << "3*5 = " << pdo_it(3, 5); // Call product thru a pointer

   pdo_it = sum;                     // Reassign pointer to sum()
   cout << endl
        << "3*(4+5) + 6 = " 
        << pdo_it(product(3, pdo_it(4, 5)), 6); // Call thru a pointer
                                                // twice
   cout << endl;
   return 0;
}

// Function to multiply two values
long product(long a, long b)
{
   return a*b;
}

// Function to add two values
long sum(long a, long b)
{
   return a+b;
}

⌨️ 快捷键说明

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