Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. //MAIN.CPP FILE
  2.  
  3. #include <stdexcept>
  4. #include <iostream>
  5. #include <string>
  6.  
  7. #include "SLinkedList.h"
  8.  
  9. using namespace std;
  10.  
  11. class Student {
  12. private:
  13. string _name;
  14. int _nsemesters;
  15.  
  16. public:
  17. void print() {
  18. cout << "Name:" << _name << "; No. of semesters=" << _nsemesters << endl;
  19. }
  20. void setName(string name) {
  21. _name = name;
  22. }
  23. void setNSemesters(int n) {
  24. _nsemesters = n;
  25. }
  26. void updateNSemesters() {
  27. _nsemesters++;
  28. }
  29.  
  30. };
  31.  
  32. class ConsecutiveNum {
  33. private:
  34. int _cnum, _addnum;
  35. public:
  36. void setNum(int cnum) {
  37. _cnum = cnum;
  38. }
  39. void increment(int addnum) {
  40.  
  41. cout <<_addnum<<endl;
  42.  
  43.  
  44. }
  45. void printE() {
  46. cout << _cnum << endl;
  47. }
  48. };
  49.  
  50. int main() {
  51.  
  52. SLinkedList<Student> students;
  53.  
  54. Student s;
  55.  
  56. SLinkedList<ConsecutiveNum> consnum;
  57.  
  58. ConsecutiveNum c;
  59. for (int i = 0; i < 5; i++) {
  60. s.setName("Student_" + to_string(i));
  61. s.setNSemesters(2);
  62.  
  63. students.addFront(s);
  64.  
  65. }
  66. while (!students.empty()) {
  67.  
  68. students.printElements().print();
  69.  
  70. students.removeFront();
  71. }
  72.  
  73. for (int i = 0; i < 10 ; i++) {
  74. c.setNum(i);
  75. c.printE();
  76. }
  77.  
  78.  
  79.  
  80.  
  81. system("pause");
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement