User Tools

Site Tools


cpp:class_templates

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
cpp:class_templates [2020/05/25 07:50] – [Ένα πιο σύνθετο παράδειγμα] gthanoscpp:class_templates [Unknown date] (current) – external edit (Unknown date) 127.0.0.1
Line 155: Line 155:
 int main() { int main() {
   Array<int, ARRAY_SIZE> a;   Array<int, ARRAY_SIZE> a;
 +  
   for(int i=0; i<ARRAY_SIZE; i++)   for(int i=0; i<ARRAY_SIZE; i++)
     a[i] = i;     a[i] = i;
      
 +  cout << "--- Printing a ---\n";
   cout << a << endl;   cout << a << endl;
-  Array<int, ARRAY_SIZE> b(a);+   
 +  Array<int, 10> b(a)
 +   
 +  cout << "--- Printing b ---\n";
   cout << b << endl;   cout << b << endl;
      
-  Array<Student, ARRAY_SIZE> sts;+  Array<Student,4> sts;
   sts[0] = Student("Kate", 12345);   sts[0] = Student("Kate", 12345);
   sts[1] = Student("Nick", 12346);   sts[1] = Student("Nick", 12346);
   sts[2] = Student("Mary", 12347);   sts[2] = Student("Mary", 12347);
 +  sts[3] = Student("Susan", 12348);
      
 +  cout << "--- Printing sts ---\n";
   cout << sts << endl;   cout << sts << endl;
          
 } }
 </code> </code>
cpp/class_templates.1590393056.txt.gz · Last modified: 2020/05/25 06:50 (external edit)