fork download
  1. /*****************************************************************
  2. Name :
  3. Date : 2017/04/04
  4. By : CharlotteHonG
  5. Final: 2017/04/04
  6. *****************************************************************/
  7. #include <iostream>
  8. using namespace std;
  9.  
  10. class A {
  11. public:
  12. A(int i=1): num(i){}
  13. int num;
  14. };
  15.  
  16. class B : public A{
  17. public:
  18. decltype(num) & alias = num;
  19. // auto & newnum = num; //error
  20. B(): A(2){
  21. cout << "num=" << alias << endl;
  22. }
  23. };
  24. //================================================================
  25. int main(int argc, char const *argv[]){
  26. B a;
  27. return 0;
  28. }
  29. //================================================================
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
num=2