考虑以下 C++ 代码:
#include <bits/stdc++.h>
template <typename T> void print_type() { std::cout << __PRETTY_FUNCTION__ << std::endl; }
class Base{
int num;
public:
Base() : num{0} {}
friend std::ostream & operator << ( std::ostream& stream, Base & obiekt){
stream<< "num: " << obiekt.num;
return stream;
}
};
int main(){
Base a{};
std::cout << a << std::endl;
std::cout << "type of a: " << std::endl;
print_type < decltype( a ) > ();
std::cout << "type of (a): " << std::endl;
print_type < …Run Code Online (Sandbox Code Playgroud)