fork(1) download
  1. #include <iostream>
  2. #define MAX_SIZE 9
  3.  
  4. using namespace std;
  5.  
  6. struct Car{};
  7.  
  8. template <typename ItemType>
  9. class List {
  10. private:
  11. ItemType itemList[10];
  12. int size;
  13. public:
  14. List();
  15. void add(ItemType);
  16. void del(int index);
  17. bool isEmpty();
  18. ItemType get(int);
  19. int length();
  20. };
  21.  
  22. template<typename ItemType>
  23. List<ItemType>::List() {
  24. size = 0;
  25. }
  26.  
  27. template<typename ItemType>
  28. void List<ItemType>::add(ItemType item) {
  29. if(size < MAX_SIZE) {
  30. itemList[size] = item;
  31. size++;
  32. } else {
  33. cout << " list is full.\n";
  34. }
  35. }
  36.  
  37. void initCarList() {
  38. List<Car> carList;
  39. Car c1;
  40. carList.add(c1);
  41. Car c2;
  42. carList.add(c2);
  43. Car c3;
  44. carList.add(c3);
  45. Car c4;
  46. carList.add(c4);
  47. }
  48.  
  49. int main() {
  50. initCarList();
  51. }
Success #stdin #stdout 0.01s 2720KB
stdin
Standard input is empty
stdout
Standard output is empty