The code below compiles and runs perfectly in Windows XP Pro, Using MS
VS 2005.
If I compile with g++ (cygwin) using the following command line:
g++ -pedantic -Weffc++ -Wall -Wctor-dtor-privacy -Wold-style-cast -
Woverloaded-virtual -o kk kk.cpp
it displays the following errors:
kk.cpp: In function `void Burp(std::ostre am&,
std::vector<std ::vector<T, std::allocator< _CharT,
std::allocator< std::vector<T, std::allocator< _CharT &)':
kk.cpp:15: error: expected `;' before "ite"
kk.cpp:15: error: `ite' undeclared (first use this function)
kk.cpp:15: error: (Each undeclared identifier is reported only once
for each function it appears in.)
Any help is appreciated, Thanks.
CODE:
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdexcept>
#include <iterator>
using namespace std;
template <typename T>
void Burp(ostream& os, vector< vector<T& vec)
{
os << "Our vector of vectors" << endl;
for(vector< vector<T::itera tor ite = vec.begin(); ite!=
vec.end();ite++ )
{
copy((*ite).beg in(), (*ite).end(), ostream_iterato r<T>(os, " "));
os << endl;
}
os << "/Our vector of vectors" << endl;
}
VS 2005.
If I compile with g++ (cygwin) using the following command line:
g++ -pedantic -Weffc++ -Wall -Wctor-dtor-privacy -Wold-style-cast -
Woverloaded-virtual -o kk kk.cpp
it displays the following errors:
kk.cpp: In function `void Burp(std::ostre am&,
std::vector<std ::vector<T, std::allocator< _CharT,
std::allocator< std::vector<T, std::allocator< _CharT &)':
kk.cpp:15: error: expected `;' before "ite"
kk.cpp:15: error: `ite' undeclared (first use this function)
kk.cpp:15: error: (Each undeclared identifier is reported only once
for each function it appears in.)
Any help is appreciated, Thanks.
CODE:
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdexcept>
#include <iterator>
using namespace std;
template <typename T>
void Burp(ostream& os, vector< vector<T& vec)
{
os << "Our vector of vectors" << endl;
for(vector< vector<T::itera tor ite = vec.begin(); ite!=
vec.end();ite++ )
{
copy((*ite).beg in(), (*ite).end(), ostream_iterato r<T>(os, " "));
os << endl;
}
os << "/Our vector of vectors" << endl;
}
Comment