User Tools

Site Tools


cpp:exception

Differences

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

Link to this comparison view

Next revisionBoth sides next revision
cpp:exception [2018/05/18 11:45] – created gthanoscpp:exception [2018/05/18 11:47] gthanos
Line 6: Line 6:
 class Vector { class Vector {
   int *array;   int *array;
-  unsigned int size;+  int size;
      
 public: public:
-  Vector(unsigned int length=0);+  Vector(int length=0);
   ~Vector();   ~Vector();
-  int &valueAt(unsigned int pos) const;  // returns a reference to element at position pos+  int &valueAt(int pos) const;  // returns a reference to element at position pos
 }; };
  
-Vector::Vector(unsigned int length) {+Vector::Vector(int length) {
   size = length;   size = length;
   array = new (nothrow) int[size];   array = new (nothrow) int[size];
Line 29: Line 29:
 } }
  
-int &Vector::valueAt(unsigned int pos) const {+int &Vector::valueAt(int pos) const {
   if(pos>=length()) {   if(pos>=length()) {
      cerr << "Invalid access position!\n";      cerr << "Invalid access position!\n";
Line 56: Line 56:
 class Vector { class Vector {
   int *array;   int *array;
-  unsigned int size;+  int size;
      
 public: public:
-  Vector(unsigned int length=0);+  Vector(int length=0);
   ~Vector();   ~Vector();
-  int &valueAt(unsigned int pos) const;  // returns a reference to element at position pos+  int &valueAt(int pos) const;  // returns a reference to element at position pos
 }; };
  
-Vector::Vector(unsigned int length) {+Vector::Vector(int length) {
   size = length;   size = length;
   array = new (nothrow) int[size];   array = new (nothrow) int[size];
Line 75: Line 75:
 } }
  
-int &Vector::valueAt(unsigned int pos) const {+int &Vector::valueAt(int pos) const {
   if(pos>=length()) {   if(pos>=length()) {
      cerr << "Invalid access position!\n";      cerr << "Invalid access position!\n";
cpp/exception.txt · Last modified: 2023/05/15 14:01 by gthanos