定义预处理器指令的格式是:
#ifndef SIZE
#define SIZE 10
int hello[SIZE];
#endif
但是当我查看以下代码时,预处理器指令无法替代:
#ifndef CREDIT_CARD_H // Avoid repeated expansion
#define CREDIT_CARD_H
#include <string> // Provides string
#include <iostream> // Provides ostream
class CreditCard
{
public:
CreditCard(const std::string& no, // Constructor
const std::string& nm, int lim, double bal = 0);
// Accessor functions
std::string getNumber()const { return number; }
std::string getName() const { return name; }
double getBalance() const { return balance; }
int getLimit() const { return limit; }
bool chargeIt(double price); // Make a charge
void makePayment(double payment); // Make a payment
private: // Private member data
std::string number; // Credit card number
std::string name; // Card owner's name
int limit; // Credit limit
double balance; // Credit card balance
};
std::ostream& operator<<(std::ostream& out, const CreditCard& c);
#endif
这是什么意思?