int ia=1, int ib=2;这两个写成一行,g++编译出错

#include
#include
#include
using namespace std;
template
T& mymax (T& a,T& b)
{
cout<<"mymax(T&,T&)"< cout<<__PRETTY_FUNCTION__< return (a }

int main(int argc, char **argv)
{
int ia=1, int ib=2;
mymax(ia,ib);
return 0;
}
在上面的涵数中,如果将:int ia=1, int ib=2;这两个写成一行,那么
在linux中用命令: g++   -o max  max.cpp
出现如下错误:
max.cpp: In function ‘int main(int, char**)’:
max.cpp:40:11: error: expected unqualified-id before ‘int’
max.cpp:41:11: error: ‘ib’ was not declared in this scope
要分成两行写:
int main(int argc, char **argv)
{
int ia=1;
int ib=2;
mymax(ia,ib);
return 0;
}
在linux中用命令: g++   -o max  max.cpp
才能通过
book@book-virtual-machine:/work/cpp_projects/16th template$ g++   -o max  max.cpp
book@book-virtual-machine:/work/cpp_projects/16th template$

你可能感兴趣的:(android,studio,3.4)