Well, i have this code:
#include <iostream>
#include "Stack.h"
#include <string>
using namespace std;
int main(int argc, char* argv[]){
Stack<string> p(100);
p.push("python");
p.push("haskell");
p.push("C++");
//p.desempilhar();
if(p.isEmpty())
cout << "Pilha vazia!\n";
else
cout << "Pilha NAO vazia!\n";
if(!p.isEmpty())
cout << "Topo: " << p.peek() << endl;
else
cout << "A pilha esta vazia!!\n";
return 0;
}
and this .h code in folder /home/matheus/Codes/C++/EstruturaDeDados:
#ifndef __STACK_H_
#define __STACK_H_
#include <iostream>
using namespace std;
/*
Declarando a criação de um template para classe Stack.
Stack aqui é um template, não uma classe propriamente dita.
Ao ser declarada da maneira correta se torna uma classe de fato.
*/
template <class T>
class Stack {
private:
int top;
T* a;
int MAX;
public:
Stack(int MAX);
bool push(T x); //Adiciona um T a stack.
bool pop(); //Remove o T mais acima da stack.
T peek(); //Retorna o T mais acima da stack.
bool isEmpty();
};
//Declarando uso de um template. template <class T>
template <class T>
//"Stack<T>" é uma classe baseada no "template <class T>".
Stack<T>::Stack(int MAX){
a = new T(MAX);
top = -1;
this->MAX = MAX;
}
//Declarando uso de um template. template <class T>
template <class T>
//"Stack<T>" é uma classe baseada no "template <class T>".
bool Stack<T>::push(T x) {
if (top >= (MAX - 1)) {
cout << "Stack Overflow" << endl;
return false;
} else {
a[++top] = x;
cout << x << " pushed into stack" << endl;
return true;
}
}
//Declarando uso de um template.
template <class T>
//"Stack<T>" é uma classe baseada no "template <class T>".
bool Stack<T>::pop() {
if (top < 0) {
cout << "Stack Underflow" << endl;
return false;
}
else {
cout << a[top--] << " Popped from stack" << endl;
return true;
}
}
//Declarando uso de um template.
template <class T>
//"Stack<T>" é uma classe baseada no "template <class T>".
T Stack<T>::peek() {
if (top < 0) {
cout << "Stack is Empty" << endl;
return NULL;
} else {
return a[top];
}
}
//Declarando uso de um template.
template <class T>
//"Stack<T>" é uma <<classe baseada no "template <class T>".
bool Stack<T>::isEmpty() {
return (top < 0);
}
#endif
When i try to compile, i receive this error i cannot even understand what it is:
In file included from 21Templates.cpp:2:
/home/matheus/Codes/C++/EstruturaDeDados/Stack.h: In instantiation of ‘Stack<T>::Stack(int) [with T = std::__cxx11::basic_string<char>]’:
21Templates.cpp:8:21: required from here
/home/matheus/Codes/C++/EstruturaDeDados/Stack.h:32:9: error: no matching function for call to ‘std::__cxx11::basic_string<char>::basic_string(int&)’
a = new T(MAX);
^~~~~~~~~~
In file included from /usr/include/c++/8/string:52,
from /usr/include/c++/8/bits/locale_classes.h:40,
from /usr/include/c++/8/bits/ios_base.h:41,
from /usr/include/c++/8/ios:42,
from /usr/include/c++/8/ostream:38,
from /usr/include/c++/8/iostream:39,
from 21Templates.cpp:1:
/usr/include/c++/8/bits/basic_string.h:614:9: note: candidate: ‘template<class _InputIterator, class> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string(_InputIterator, _InputIterator, const _Alloc&)’
basic_string(_InputIterator __beg, _InputIterator __end,
^~~~~~~~~~~~
/usr/include/c++/8/bits/basic_string.h:614:9: note: template argument deduction/substitution failed:
In file included from 21Templates.cpp:2:
/home/matheus/Codes/C++/EstruturaDeDados/Stack.h:32:9: note: candidate expects 3 arguments, 1 provided
a = new T(MAX);
^~~~~~~~~~
In file included from /usr/include/c++/8/string:52,
from /usr/include/c++/8/bits/locale_classes.h:40,
from /usr/include/c++/8/bits/ios_base.h:41,
from /usr/include/c++/8/ios:42,
from /usr/include/c++/8/ostream:38,
from /usr/include/c++/8/iostream:39,
from 21Templates.cpp:1:
/usr/include/c++/8/bits/basic_string.h:576:7: note: candidate: ‘std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&&, const _Alloc&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’
basic_string(basic_string&& __str, const _Alloc& __a)
^~~~~~~~~~~~
/usr/include/c++/8/bits/basic_string.h:576:7: note: candidate expects 2 arguments, 1 provided
/usr/include/c++/8/bits/basic_string.h:572:7: note: candidate: ‘std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, const _Alloc&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’
basic_string(const basic_string& __str, const _Alloc& __a)
^~~~~~~~~~~~
/usr/include/c++/8/bits/basic_string.h:572:7: note: candidate expects 2 arguments, 1 provided
/usr/include/c++/8/bits/basic_string.h:568:7: note: candidate: ‘std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string(std::initializer_list<_Tp>, const _Alloc&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’
basic_string(initializer_list<_CharT> __l, const _Alloc& __a = _Alloc())
^~~~~~~~~~~~
/usr/include/c++/8/bits/basic_string.h:568:7: note: no known conversion for argument 1 from ‘int’ to ‘std::initializer_list<char’
/usr/include/c++/8/bits/basic_string.h:541:7: note: candidate: ‘std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’
basic_string(basic_string&& __str) noexcept
^~~~~~~~~~~~
/usr/include/c++/8/bits/basic_string.h:541:7: note: no known conversion for argument 1 from ‘int’ to ‘std::__cxx11::basic_string<char>&&’
/usr/include/c++/8/bits/basic_string.h:529:7: note: candidate: ‘std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type, _CharT, const _Alloc&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type = long unsigned int]’
basic_string(size_type __n, _CharT __c, const _Alloc& __a = _Alloc())
^~~~~~~~~~~~
/usr/include/c++/8/bits/basic_string.h:529:7: note: candidate expects 3 arguments, 1 provided
/usr/include/c++/8/bits/basic_string.h:514:7: note: candidate: ‘std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string(const _CharT*, const _Alloc&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’ <near match>
basic_string(const _CharT* __s, const _Alloc& __a = _Alloc())
^~~~~~~~~~~~
/usr/include/c++/8/bits/basic_string.h:514:7: note: conversion of argument 1 would be ill-formed:
In file included from 21Templates.cpp:2:
/home/matheus/Codes/C++/EstruturaDeDados/Stack.h:32:9: error: invalid conversion from ‘int’ to ‘const char*’ [-fpermissive]
a = new T(MAX);
^~~~~~~~~~
In file included from /usr/include/c++/8/string:52,
from /usr/include/c++/8/bits/locale_classes.h:40,
from /usr/include/c++/8/bits/ios_base.h:41,
from /usr/include/c++/8/ios:42,
from /usr/include/c++/8/ostream:38,
from /usr/include/c++/8/iostream:39,
from 21Templates.cpp:1:
/usr/include/c++/8/bits/basic_string.h:499:7: note: candidate: ‘std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string(const _CharT*, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type, const _Alloc&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type = long unsigned int’
basic_string(const _CharT* __s, size_type __n,
^~~~~~~~~~~~
/usr/include/c++/8/bits/basic_string.h:499:7: note: candidate expects 3 arguments, 1 provided
/usr/include/c++/8/bits/basic_string.h:481:7: note: candidate: ‘std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type, const _Alloc&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type = long unsigned int]’
basic_string(const basic_string& __str, size_type __pos,
^~~~~~~~~~~~
/usr/include/c++/8/bits/basic_string.h:481:7: note: candidate expects 4 arguments, 1 provided
/usr/include/c++/8/bits/basic_string.h:465:7: note: candidate: ‘std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type = long unsigned int]’
basic_string(const basic_string& __str, size_type __pos,
^~~~~~~~~~~~
/usr/include/c++/8/bits/basic_string.h:465:7: note: candidate expects 3 arguments, 1 provided
/usr/include/c++/8/bits/basic_string.h:450:7: note: candidate: ‘std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type, const _Alloc&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type = long unsigned int]’
basic_string(const basic_string& __str, size_type __pos,
^~~~~~~~~~~~
/usr/include/c++/8/bits/basic_string.h:450:7: note: candidate expects 3 arguments, 1 provided
/usr/include/c++/8/bits/basic_string.h:437:7: note: candidate: ‘std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’
basic_string(const basic_string& __str)
^~~~~~~~~~~~
/usr/include/c++/8/bits/basic_string.h:437:7: note: no known conversion for argument 1 from ‘int’ to ‘const std::__cxx11::basic_string<char>&’
/usr/include/c++/8/bits/basic_string.h:429:7: note: candidate: ‘std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string(const _Alloc&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’
basic_string(const _Alloc& __a) _GLIBCXX_NOEXCEPT
^~~~~~~~~~~~
/usr/include/c++/8/bits/basic_string.h:429:7: note: no known conversion for argument 1 from ‘int’ to ‘const std::allocator<char>’
/usr/include/c++/8/bits/basic_string.h:420:7: note: candidate: ‘std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string() [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’
basic_string()
^~~~~~~~~~~~
/usr/include/c++/8/bits/basic_string.h:420:7: note: candidate expects 0 arguments, 1 provided
The .h is a template for a stack, im trying to code all of this with: g++ -I /home/matheus/Codes/C++/EstruturaDeDados/ -o 21Templates 21Templates.cpp, but im receiving over and over again this error.
How i solve this? And what exactly is that error?
This statement
a = new T(MAX);
tries to create an object of the type std::string from the integer value MAX. However the class std::string has no such a constructor.
It seems you mean
a = new T[MAX];
that is you want to create an array of objects of the type std::string.
This function
T Stack<T>::peek() {
if (top < 0) {
cout << "Stack is Empty" << endl;
return NULL;
} else {
return a[top];
}
}
is also wrong because creating an object of the type std::string from a null pointer results in undefined behavior. You should throw an exception for example std::out_of_range.
Pay attention to that the class has no destructor.
Instead of the dynamically allocated array you could use the class std::vector<std::string>.
If you are trying to make an array, change this line
a = new T(MAX);
to this
a = new T[MAX];
and remember to delete it later or you'll leak that memory
Stack::~Stack()
{
delete[] a;
}
Here is my code, I'm not sure why the error is being thrown - the method is supposed to operate on a pointer object and print out its values.
main:
cout<<"Deleted item is: "<<displayRecord(tmp)/*tmp->entry*/<<endl;
void displayRecord(PRecord* pr) {
cout<<"Time: "<<pr->time<<"\tEntry data: \""<<pr->entry<<'"'<<endl;
}
header.h:
#include <iostream>
using namespace std;
struct PRecord {
long time;
string entry;
struct PRecord *link;
};
void displayRecord(PRecord* pr);
I am getting this error: error: no match for 'operator <<
error: no match for 'operator<<' in 'std::operator<< [with _Traits = std::char_traits<char>](((std::basic_ostream<char, std::char_traits<char> >&)(& std::cout)), ((const char*)"Deleted item is: ")) << Priority_Queue::displayRecord(tmp)'
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/ostream:108: note: candidates are: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ostream<_CharT, _Traits>& (*)(std::basic_ostream<_CharT, _Traits>&)) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/ostream:117: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ios<_CharT, _Traits>& (*)(std::basic_ios<_CharT, _Traits>&)) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/ostream:127: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(std::ios_base& (*)(std::ios_base&)) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/lib/gcc/x86_64-redhat-linux
The error is clear you want to use
cout << "Deleted item is: " << Priority_Queue::displayRecord(tmp);
but it doesn't compile because displayRecord returns no value. It returns void type what is not printable and cannot be used as argument for operator<<.
Call
cout << "Deleted item is: ";
Priority_Queue::displayRecord(tmp);
I'm trying to output content of boost::asio::streambuf object with boost::log library. I defined operator<< overload in the following way:
ostream& operator<<(ostream& ostr, const boost::asio::streambuf& buffer)
{
for (size_t i = 0; i < buffer.size(); ++i)
{
ostr << hex << (int) buffer_cast<const char*>(buffer.data())[i] << " ";
}
return ostr;
}
But after trying to output the content of the buffer:
BOOST_LOG_TRIVIAL(trace) << buffer;
I have the following error:
In file included from
/home/bobeff/work/asio_netcomm_poc/third_party/lib/boost/boost/log/sources/record_ostream.hpp:31:0,
from /home/bobeff/work/asio_netcomm_poc/third_party/lib/boost/boost/log/trivial.hpp:23,
from /home/bobeff/work/asio_netcomm_poc/server/src/server.cpp:14:
/home/bobeff/work/asio_netcomm_poc/third_party/lib/boost/boost/log/utility/formatting_ostream.hpp:
In instantiation of 'typename
boost::log::v2_mt_posix::aux::enable_if_formatting_ostream::type boost::log::v2_mt_posix::operator<<(StreamT&, T&)
[with StreamT =
boost::log::v2_mt_posix::basic_formatting_ostream; T =
boost::asio::basic_streambuf<>; typename
boost::log::v2_mt_posix::aux::enable_if_formatting_ostream::type =
boost::log::v2_mt_posix::basic_formatting_ostream&]':
/home/bobeff/work/asio_netcomm_poc/third_party/lib/boost/boost/log/sources/record_ostream.hpp:212:51:
required from 'typename
boost::log::v2_mt_posix::aux::enable_if_record_ostream::type boost::log::v2_mt_posix::operator<<(StreamT&, T&)
[with StreamT = boost::log::v2_mt_posix::basic_record_ostream; T
= boost::asio::basic_streambuf<>; typename boost::log::v2_mt_posix::aux::enable_if_record_ostream::type =
boost::log::v2_mt_posix::basic_record_ostream&]'
/home/bobeff/work/asio_netcomm_poc/server/src/server.cpp:88:47:
required from here
/home/bobeff/work/asio_netcomm_poc/third_party/lib/boost/boost/log/utility/formatting_ostream.hpp:840:19:
error: cannot bind
'boost::log::v2_mt_posix::basic_formatting_ostream::ostream_type
{aka std::basic_ostream}' lvalue to 'std::basic_ostream&&'
strm.stream() << value;
^ In file included from /usr/include/c++/4.8/iostream:39:0,
from /home/bobeff/work/asio_netcomm_poc/server/src/server.cpp:1:
/usr/include/c++/4.8/ostream:602: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; _Tp =
boost::asio::basic_streambuf<>]'
operator<<(basic_ostream<_CharT, _Traits>&& __os, const _Tp& __x)
^
What is the right way to output the content of the buffer?
Your operator<< is not found by ADL. See the first part of this answer.
I'm about to compile a pretty easy 'Hello, world' using libconfig. But when I compile such code:
#include <iostream>
#include <libconfig.h++>
libconfig::Config cfg;
std::string target = "World";
int main(void)
{
try
{
cfg.readFile("greetings.cfg");
}
catch (const libconfig::FileIOException &fioex)
{
std::cerr << "I/O error while reading file." << std::endl;
return 1;
}
catch (const libconfig::ParseException &pex)
{
std::cerr << pex.getFile() << " " << pex.getLine()
<< ": " << pex.getError() << std::endl;
return 1;
}
try
{
target = cfg.lookup("target");
}
catch (const libconfig::SettingNotFoundException &nfex)
{
std::cerr << "No target set in configuration file. Using default." << std::endl;
}
std::cout << "Hello, " << target << "!" << std::endl;
return 0;
}
I have this error:
example1.cpp: In function 'int main()':
example1.cpp:28: error: ambiguous overload for 'operator=' in 'target = cfg.libconfig::Config::lookup(((const char*)"target"))
/usr/include/c++/4.2/bits/basic_string.h:490: note: candidates are: std::basic_string<_CharT, _Traits, _Alloc>& std::basic_string<_CharT, _Traits, _Alloc>::operator=(const std::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]
/usr/include/c++/4.2/bits/basic_string.h:498: note: std::basic_string<_CharT, _Traits, _Alloc>& std::basic_string<_CharT, _Traits, _Alloc>::operator=(const _CharT*) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]
/usr/include/c++/4.2/bits/basic_string.h:509: note: std::basic_string<_CharT, _Traits, _Alloc>& std::basic_string<_CharT, _Traits, _Alloc>::operator=(_CharT) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]
According to Chapter 4 of the documentation, on page 19, lookup returns a Setting&, not a string.
Now, according to page 20, Setting has a bunch of implicit conversions to various types, including std::string. Here, the conversion to std::string is ambiguous in the presence of the conversion to const char*, since std::string has constructors accepting both with equal rank.
This problem is actually explicitly described on page 21, wherein resolving the ambiguity with an explicit conversion (or "cast") is suggested, or the use of the member c_str() rather than of the conversion operators:
target = cfg.lookup("target").c_str();
void webparser(const string siteurl,string filename)
{
stringstream ss;
ss << "lynx -dump '" << siteurl << "'" > filename;
system(ss.str().c_str());
}
How do I use filename instead of file.txt in the above example?
Initially my line for ss was
ss << "lynx -dump '" << siteurl << "' > file.txt";
But I decided to change it to use the value from a parameter, so I added filename.
Below is my error message
main.cpp: In function ‘void webparser(std::string, std::string)’:
main.cpp:244:46: error: no match for ‘operator>’ in ‘std::operator<< [with _Traits = std::char_traits<char>]((* & std::operator<< [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]((* & std::operator<< [with _Traits = std::char_traits<char>]((* & ss.std::basic_stringstream<char>::<anonymous>.std::basic_iostream<char>::<anonymous>), ((const char*)"lynx -dump \'"))), (* & siteurl))), ((const char*)"\'")) > filename’
main.cpp:244:46: note: candidates are:
/usr/include/c++/4.6/bits/stl_pair.h:220:5: note: template<class _T1, class _T2> bool std::operator>(const std::pair<_T1, _T2>&, const std::pair<_T1, _T2>&)
/usr/include/c++/4.6/bits/stl_iterator.h:303:5: note: template<class _Iterator> bool std::operator>(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_Iterator>&)
/usr/include/c++/4.6/bits/stl_iterator.h:353:5: note: template<class _IteratorL, class _IteratorR> bool std::operator>(const std::reverse_iterator<_IteratorL>&, const std::reverse_iterator<_IteratorR>&)
/usr/include/c++/4.6/bits/basic_string.h:2547:5: note: template<class _CharT, class _Traits, class _Alloc> bool std::operator>(const std::basic_string<_CharT, _Traits, _Alloc>&, const std::basic_string<_CharT, _Traits, _Alloc>&)
/usr/include/c++/4.6/bits/basic_string.h:2559:5: note: template<class _CharT, class _Traits, class _Alloc> bool std::operator>(const std::basic_string<_CharT, _Traits, _Alloc>&, const _CharT*)
/usr/include/c++/4.6/bits/basic_string.h:2571:5: note: template<class _CharT, class _Traits, class _Alloc> bool std::operator>(const _CharT*, const std::basic_string<_CharT, _Traits, _Alloc>&)
/usr/include/c++/4.6/bits/stl_iterator.h:842:5: note: template<class _Iterator, class _Container> bool __gnu_cxx::operator>(const __gnu_cxx::__normal_iterator<_Iterator, _Container>&, const __gnu_cxx::__normal_iterator<_Iterator, _Container>&)
/usr/include/c++/4.6/bits/stl_iterator.h:836:5: note: template<class _IteratorL, class _IteratorR, class _Container> bool __gnu_cxx::operator>(const __gnu_cxx::__normal_iterator<_IteratorL, _Container>&, const __gnu_cxx::__normal_iterator<_IteratorR, _Container>&)
make: *** [main.o] Error 1
Replace
ss << "lynx -dump '" << siteurl << "'" > filename;
with
ss << "lynx -dump '" << siteurl << "'" << filename;
or, to be consistent with your original code:
ss << "lynx -dump '" << siteurl << "' > " << filename;