User Tools

Site Tools


cpp:exception

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revisionBoth sides next revision
cpp:exception [2023/05/15 13:57] gthanoscpp:exception [2023/05/15 13:58] gthanos
Line 109: Line 109:
 int main() { int main() {
   int size;   int size;
-  do { +   
-    cout << "Enter verctor size: "; +  cout << "Enter verctor size: "; 
-    cin >> size; +  cin >> size; 
-    try { +  try { 
-      Vector v(size); +    Vector v(size); 
-    } catch(std::bad_alloc ex) { +  } catch(std::bad_alloc ex) { 
-      if(size<=0) { +    if(size<=0) { 
-        cout << "Vector size should be a positive integer! Retry...\n"; +      cout << "Vector size should be a positive integer! Retry...\n"; 
-        continue+      continue;
-      } +
-      exit(-1);+
     }     }
-    for(int i=0; i<size; i++) +    exit(-1)
-    v.valueAt(i) = 100-1; +  } 
-  } while(size<1);  +
 } }
 </code> </code>
cpp/exception.txt · Last modified: 2023/05/15 14:01 by gthanos