编译“error:”时出现错误”“之前应为嵌套名称说明符
代码为
using range = std::pair<float,float> ;
range make_range( float a, float b ) { return { std::min(a,b), std::max(a,b) } ; }
bool intersects( range a, range b )
{
if( a > b ) std::swap(a,b) ;
return a.second >= b.first ;
}
我使用的是Ubuntu 12.04、GCC 4.6和代码块10.05
4条答案
按热度按时间chhkpiq41#
我在一个文件中创建了这个:
并使用***g++ -std=c++11program_name.cc***编译和运行时没有任何问题。
nhaq1z212#
您的意思可能如下:
请记住使用C11(否则您将收到警告:扩展初始化器列表仅在使用-std=c11或-std=gnu++11时可用)
xytpbqjk3#
试试看:
olhwl3o24#
不是因为头文件,可能是因为c版本不是c11(尝试将编译选项设置为-std=c++11)