C++ Primer 4/e says, every pair has 2 members named <firstand <lastbut
g++ refuses to accept so. I have just created a pir and trying to print
its both members:
#include<iostre am>
#include<string >
#include<utilit y>
int main()
{
std::pair<std:: string, intmy_pair;
std::cin >my_pair.firs t >my_pair.last ;
std::cout << my_pair.first << "\n"
<< my_pair.last << "\n";
return 0;
}
========= OUTPUT ==============
/home/arnuld/programs $ g++ -ansi -pedantic -Wall -Wextra test.cpp
test.cpp: In function ‘int main()’:
test.cpp:12: error: ‘struct std::pair<std:: basic_string<ch ar,
std::char_trait s<char>, std::allocator< char, int>’
has no member named ‘last’
test.cpp:15: error: ‘struct std::pair<std:: basic_string<ch ar,
std::char_trait s<char>,std::al locator<char, int>’ has no member named
‘last’ /home/arnuld/programs $
--
http://lispmachine.wordpress.com/