我声明了一个自动类型的测试变量,但现在我不知道如何访问它。我知道如何使这个程序在没有的情况下工作,auto
但在这里我想知道如何访问该auto
变量。
int main() {
auto test = {'1','S'};
std::cout<<test; //error no match for operator... i tried using *test or *test[0] but no solution.
cin.get();
return 0;
}
编译器日志:
Compiler: mingw
Executing g++.exe...
g++.exe "C:\Users\Arpit\Desktop\delete.cpp" -o "C:\Users\Arpit\Desktop\delete.exe" -std=c++11
C:\Users\Arpit\Desktop\delete.cpp: In function 'int main()':
C:\Users\Arpit\Desktop\delete.cpp:5:12: error: cannot bind 'std::ostream {aka std::basic_ostream<char>}' lvalue to 'std::basic_ostream<char>&&'
In file included from c:\program files\codeblocks\mingw\bin\../lib/gcc/mingw32/4.7.1/include/c++/iostream:40:0,
from C:\Users\Arpit\Desktop\delete.cpp:1:
c:\program files\codeblocks\mingw\bin\../lib/gcc/mingw32/4.7.1/include/c++/ostream:600:5: error: initializing argument 1 of 'std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&&, const _Tp&) [with _CharT = char; _Traits = std::char_traits<char>; _Tp = std::initializer_list<char>]'
Execution terminated
如何打印test
?