C++

tempparm.h

  1. #ifndef PRO1_TEMPPARM_H
  2. #define PRO1_TEMPPARM_H
  3. class tempparm {
  4. };
  5. #endif //PRO1_TEMPPARM_H

tempparm.cpp

  1. #include "../stacktp.h"
  2. #include <iostream>
  3. using namespace std;
  4. template <template <typename T> class Thing>
  5. class Crab{
  6. private:
  7. Thing<int> s1;
  8. Thing<double > s2;
  9. public:
  10. Crab(){};
  11. bool push(int a, double x){ return s1.push(a) && s2.push(x);}
  12. bool pop(int & a, double & x){ return s1.pop(a) && s2.pop(x);}
  13. };
  14. void test(){
  15. Crab<Stack> nebula;
  16. int ni;
  17. double nb;
  18. cout << "Enter int double pairs ,such as 4 3.5 (0 0 to be and): \n";
  19. while (cin >> ni >> nb && ni > 0 && nb > 0) {
  20. if (!nebula.push(ni, nb))
  21. break;
  22. }
  23. while (nebula.pop(ni, nb)) {
  24. cout << ni << ", " << nb << endl;
  25. }
  26. cout << "Done.\n";
  27. }