test.cpp 367 B

12345678910111213141516171819202122232425262728
  1. #include<iostream>
  2. #include<typeinfo>
  3. template<typename TYPE>
  4. union ty
  5. {
  6. int k,
  7. TYPE type
  8. };
  9. int main()
  10. {
  11. ty<double> t;
  12. t.k=15;
  13. if(typeid(t)==typeid(double))
  14. {
  15. std::cout<<"int"<<t.TYPE<<std::endl;
  16. }
  17. int a[10]={0};
  18. for(auto& i : a)
  19. {
  20. i=1;
  21. }
  22. for(auto j :a)
  23. {
  24. std::cout<<j<<std::endl;
  25. }
  26. }