Skip to content

Instantly share code, notes, and snippets.

@rafalcieslak
Last active July 15, 2018 02:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rafalcieslak/1200e25ce296ad68b13abbe87f9c7fd2 to your computer and use it in GitHub Desktop.
Save rafalcieslak/1200e25ce296ad68b13abbe87f9c7fd2 to your computer and use it in GitHub Desktop.
C++ Quine
#include <iostream>
int main() {
std::string code1 = R"(
#include <iostream>
int main() {
)";
std::string code2 = R"(
std::cout << code1
<< " std::string code1 = R\"(" << code1 << ")\";\n"
<< " std::string code2 = R\"(" << code2 << ")\";\n"
<< code2;
}
)";
std::cout << code1
<< " std::string code1 = R\"(" << code1 << ")\";\n"
<< " std::string code2 = R\"(" << code2 << ")\";\n"
<< code2;
}
@xakepp35
Copy link

xakepp35 commented Jul 15, 2018

std::cout << code1
error C2679: binary '<<': no operator found which takes a right-hand operand of type 'std::string' (or there is no acceptable conversion)

You forget to
#include < string >

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment