Alright so here goes my basic attempt (
first ever quine) (the output is the quine, not the pasted code itself):
#include <iostream>
#include <string>
using namespace std;
int main(){
string q =
"#include <iostream>\n"
"#include<string>\n"
"using namespace std;\n"
"int main(){ "
"string q = \x22\x22; "
"string p = q; "
"string c; "
"c.push_back(0x5C); "
"c.push_back('x'); "
"c.push_back('2'); "
"c.push_back('2'); "
"string n; "
"n.push_back(0x5C); "
"n.push_back('n'); "
"p.replace(82, 1, c); "
"p.replace(81, 1, c); "
"p.replace(57, 1, n); "
"p.replace(36, 1, n); "
"p.replace(19, 1, n); "
"q.insert(82, p); "
"cout << q << endl; "
"return 0; }";
string p = q;
string c;
c.push_back(0x5C);
c.push_back('x');
c.push_back('2');
c.push_back('2');
string n;
n.push_back(0x5C);
n.push_back('n');
p.replace(82, 1, c);
p.replace(81, 1, c);
p.replace(57, 1, n);
p.replace(36, 1, n);
p.replace(19, 1, n);
q.insert(82, p);
cout << q << endl;
return 0;
}
The output quine.
#include <iostream>
#include<string>
using namespace std;
int main(){ string q = "#include <iostream>\n#include<string>\nusing namespace std;\nint main(){ string q = \x22\x22; string p = q; string c; c.push_back(0x5C); c.push_back('x'); c.push_back('2'); c.push_back('2'); string n; n.push_back(0x5C); n.push_back('n'); p.replace(82, 1, c); p.replace(81, 1, c); p.replace(57, 1, n); p.replace(36, 1, n); p.replace(19, 1, n); q.insert(82, p); cout << q << endl; return 0; }"; string p = q; string c; c.push_back(0x5C); c.push_back('x'); c.push_back('2'); c.push_back('2'); string n; n.push_back(0x5C); n.push_back('n'); p.replace(82, 1, c); p.replace(81, 1, c); p.replace(57, 1, n); p.replace(36, 1, n); p.replace(19, 1, n); q.insert(82, p); cout << q << endl; return 0; }
I must add that this quine is very close to geek's second one. Same idea, more blabber. It's a bit different in how it handles escaping those pesky characters between the stored string and the actual quine.