it's friday
This commit is contained in:
14
Lab2/row.cpp
14
Lab2/row.cpp
@@ -43,16 +43,18 @@ Row::~Row(){
|
|||||||
|
|
||||||
// access operator (const)
|
// access operator (const)
|
||||||
double Row::operator[](unsigned int column) const{
|
double Row::operator[](unsigned int column) const{
|
||||||
//finish
|
if (column >= length) {
|
||||||
double result;
|
throw(out_of_range("Column is out of range"));
|
||||||
return result;
|
}
|
||||||
|
return row_data[column];
|
||||||
}
|
}
|
||||||
|
|
||||||
// access operator (non-const)
|
// access operator (non-const)
|
||||||
double& Row::operator[](unsigned int column){
|
double& Row::operator[](unsigned int column){
|
||||||
//finish
|
if (column >= length) {
|
||||||
double result;
|
throw(out_of_range("Column is out of range"));
|
||||||
return result;
|
}
|
||||||
|
return row_data[column];
|
||||||
}
|
}
|
||||||
|
|
||||||
// assignment operator
|
// assignment operator
|
||||||
|
|||||||
@@ -58,6 +58,11 @@ char& Dog::operator[](int index){
|
|||||||
return name[index];
|
return name[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Dog Dog::puppy(int namelength, char * name){
|
||||||
|
Dog p(0, namelength, name);
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
ostream& operator<<(ostream& os, const Dog& d){
|
ostream& operator<<(ostream& os, const Dog& d){
|
||||||
for(int i = 0; i< d.namelength; i++) {
|
for(int i = 0; i< d.namelength; i++) {
|
||||||
os << d[i];
|
os << d[i];
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ using namespace std;
|
|||||||
class Dog {
|
class Dog {
|
||||||
public:
|
public:
|
||||||
Dog(int age, int namelength, char * name);
|
Dog(int age, int namelength, char * name);
|
||||||
|
// has to be dog object, not reference
|
||||||
|
static Dog Dog::puppy(int namelength, char *name);
|
||||||
Dog(const Dog& from);
|
Dog(const Dog& from);
|
||||||
~Dog();
|
~Dog();
|
||||||
Dog& operator=(const Dog& rhs);
|
Dog& operator=(const Dog& rhs);
|
||||||
|
|||||||
Reference in New Issue
Block a user