【发布时间】:2017-04-07 19:45:37
【问题描述】:
为了方便使用,我尝试使用#typedef 将类型声明为我自己的自定义名称:
class Solution {
public:
void dfs(vector<vector<char>>& board, int i, int j)
{
using namespace std;
#typedef std::pair<int, int> myStateType;
std::queue<myStateType> q; // error on this line
...
}
};
但是,编译错误提示在这一行std::queue<myStateType> q;:
'myStateType' 未在此范围内声明
我还没有弄清楚这个错误是怎么发生的?有任何想法吗?提前致谢!
【问题讨论】:
-
#是实际代码的一部分吗?typedef std::pair<int, int> myStateType;应该没问题。 -
我觉得奇怪的是,您使用的是
using namespace std;,但还指定了std::命名空间 IIF 该行出现在using语句之后?
标签: c++ visual-studio scope macros typedef