SHARE
TWEET

Untitled

a guest Feb 19th, 2019 83 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int main()
  2.     {
  3.         string name;
  4.         int grade;
  5.         vector<wilsonStudent::student> vectorOfStudents;
  6.  
  7.         wilsonStudent::student student1("John", 95);
  8.         vectorOfStudents.push_back(student1);
  9.         .... repeats several times for all data
  10.  
  11.  
  12.        // create the HTML table object and set its members HTMLTable hTable;
  13.        wilsonOutput::HTMLTable hTable;
  14.        hTable.setRow(vectorOfStudents);
  15.  
  16.        .... other code
  17.        return 0;
  18.    }
  19.    
  20. #ifndef OUTPUTTOHTML_H
  21.     #define OUTPUTTOHTML_H
  22.  
  23.    namespace wilsonOutput
  24.    {
  25.    class HTMLTable
  26.        {
  27.        private:
  28.  
  29.        public:
  30.            void setRow(vector<wilsonStudent::student> &vectorOfObjects);
  31.            // Set headers for the table columns
  32.        };
  33.    }
  34.    #endif
  35.    
  36. void wilsonOutput::HTMLTable::setRow(vector<wilsonStudent::student> &vectorOfObjects)
  37.     {
  38.         int vectorSize = vectorOfObjects.size();
  39.  
  40.         for (unsigned int counter = 0; counter < vectorSize; counter++)
  41.         {
  42.             int grade = vectorOfObjects.getGrade();
  43.             string name = vectorOfObjects.getName();
  44.  
  45.             std::stringstream out;
  46.             out << grade;
  47.             string gradeString = out.str();
  48.  
  49.             string arrayOfStudentInformation[] = {name, gradeString, ""};
  50.  
  51.             addRow(StringVector(arrayOfStudentInformation));
  52.         }
  53.  
  54.  
  55.    }
  56.    
  57. int grade = vectorOfObjects.getGrade();
  58. string name = vectorOfObjects.getName();
  59.    
  60. int grade = vectorOfObjects[counter].getGrade();
  61. string name = vectorOfObjects[counter].getName();
  62.    
  63. for (vector<int>::iterator it = v.begin(); it!=v.end(); ++it) {
  64.   cout << *it << endl;
  65. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top