currency.h

来自「一本语言类编程书籍」· C头文件 代码 · 共 18 行

H
18
字号
// Exercise 11.2 A currency converter    File: currency.h
// currency.h Definition for Currency structure
#ifndef CURRENCY_H
#define CURRENCY_H

// Structure representing a currency
struct Currency {
  char name[20];                    // Currency name
  double amount;                    // An amount in this currency
  double rate;                      // Value of 1 unit of this currency in US dollars
  char code[4];                     // Currency code - 3 characters e.g. "USD"

  double convert(Currency amount);  // Convert amount to this currency
  void set_amount(double amount);   // Set an amount in this currency
  void show();                      // Display the amount of this currence
};

#endif

⌨️ 快捷键说明

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