Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*g++ -g -std=c++14 file.cpp -o file.exe
- * file.cpp:
- */
- #include <stdio.h>
- #include <iostream>
- #include <string>
- class b {
- public:
- b(const char *n) : n(n) {};
- operator const char *() const {
- return n;
- }
- const char *n;
- };
- class a {
- public:
- a(const char *n) : n(n) {};
- operator b() const {
- return b(n);
- }
- const char *n;
- };
- int main(int argc, char **argv) {
- a x("hello");
- b y = x;
- std::string z = (const char*)y;
- std::cout << y;
- std::cout << (b)x;
- //std::cout << x; would fail
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement