[英]Is there a method to let #define normal literals as essential operators of C++?
我參加競爭性編程。 鑒於我迫切需要一個基本的模板來記憶,所以我非常使用宏。
例如,我使用
#define large long long
large value;
不過,有兩個運算符讓我很惱火: <<
和>>
as of input 和 output。
我想看到類似的東西
#include <iostream>
using namespace std;
#define and <<
#define with >>
#define print cout
#define input cin
int main() {
long long value1, value2;
input value1 with value2;
print value1 and value2;
}
我希望這個程序能夠回應用戶輸入的兩個整數值。
但是,我經常收到一條錯誤消息,指出Cannot #define something as an operator
。 我該如何解決? 如果我不能,是否有#define and <<
的替代品? 我非常感謝你的回應。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.