小编Moh*_*arg的帖子

C++ - 使用typeof运算符给出错误的宏

我正在从这个topcoder链接学习C++(STL):https://www.topcoder.com/community/data-science/data-science-tutorials/power-up-c-with-the-standard-template-library- part-1 / 并且作者使用了宏,这是我第一次学习.我试图以下面的方式使用它,但我得到一些错误:

#include <iostream>
#include <vector>
#include <set>

//Macros

#define tr(container, it)\
    for(typeof(container.begin()) it = container.begin(); it!=container.end(); it++);

using namespace std;

int main()
{
    set< pair<string, pair< int, vector<int> > > >SS; 
    int total = 0; 
    tr(SS, it) { 
        total += it->second.first; 
    }
    return 0; 
}
Run Code Online (Sandbox Code Playgroud)

错误:在使用宏的行上,我收到一个错误 - >'it'未在此范围内声明.请帮忙!谢谢!

c++ macros

1
推荐指数
1
解决办法
1846
查看次数

标签 统计

c++ ×1

macros ×1