Answer the question
In order to leave comments, you need to log in
Why doesn't operator overloading work?
For educational purposes, I am writing a class on sys / socket, to work with sockets, in fact.
https://github.com/nkt/cpp-socket/blob/master/src/... is the method.
https://github.com/nkt/cpp-socket/blob/master/chat... is its usage.
Xcode issues
Undefined symbols for architecture x86_64:
"Socket& operator<<<char const [16]>(Socket&, char const (&) [16])", referenced from:
_main in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
#include <iostream>
#include <string>
class test
{
public:
void send(std::string str);
template <class T>
friend test &operator <<(test &tst, T &message);
};
void test::send(std::string str)
{
std::cout << str;
}
template <class T>
test &operator <<(test &tst, T &message)
{
tst.send(std::string(message));
return tst;
}
int main()
{
test t;
t << "hello world!\n";
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question