Last active
May 30, 2018 10:18
-
-
Save akindyakov/7aea290e534674915fa46e3e795bdf29 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% g++ -std=c++11 -c main.cpp [0] | |
main.cpp: In function ‘int main()’: | |
main.cpp:8:25: error: invalid use of incomplete type ‘class Status’ | |
std::cout << f.second().str() << '\n'; | |
^ | |
In file included from main.cpp:1:0: | |
first.h:3:7: error: forward declaration of ‘class Status’ | |
class Status; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "first.h" | |
#include "status.h" | |
Status First::second() const { | |
return Status{}; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
class Status; | |
class First { | |
public: | |
explicit First() = default; | |
Status second() const; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "first.h" | |
#include <iostream> | |
int main() { | |
auto f = First(); | |
std::cout << f.second().str() << '\n'; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "status.h" | |
std::string Second::str() const { | |
return std::string{"hello"}; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include <string> | |
class Status { | |
public: | |
explicit Status() = default; | |
std::string str() const; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment