作者Ygulu (生活以下)
看板C_and_CPP
标题[问题] 巨集
时间Wed Apr 1 11:43:01 2009
#include <iostream>
using namespace std;
#define MAX(x, y) (x>y ? x:y)
#define PRODUCT(x, y) (x)*(y)
#define mixxx(x, y) x##y
#define ShowValue(x)
{
cout << x << "=" << x << endl;
}
int main()
{
int aab=12345;
cout << MAX(5+1, 3+8) << endl;
cout << PRODUCT(6+3, 1+2) << endl;
cout << mixxx(aa, b) << endl;
ShowValue(3);
system("pause");
}
我照书上打的
但编译时 他一直说第八行的大括号有问题
8 expected unqualified-id before '{' token
8 expected `,' or `;' before '{' token
请问是哪里出错了
谢谢
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 114.42.216.102
1F:→ adrianshum:Macro 只能一行, 请用 \ 在行尾 04/01 11:48
2F:推 littleshan: #define 若有换行,要在行尾加上 \ 04/01 11:50
3F:→ Ygulu:书上有 我以为按enter就可以了 感谢感谢 04/01 11:53