-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_class.cpp
More file actions
55 lines (49 loc) · 978 Bytes
/
Copy pathtest_class.cpp
File metadata and controls
55 lines (49 loc) · 978 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*
* pj92singh
* Testing c++ class
* Calling Rectangle class and Sedan class
* building objects based of this calls
*
* Building more memebers moving forward
*/
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
class Rectangle {
int width, height;
public:
void set_values (int,int);
int area() {return width*height;}
};
class Sedan{
string make = "";
public:
void set_theMake(string);
string get_theMake(){ return make; }
};
void Rectangle::set_values (int x, int y) {
width = x;
height = y;
}
void Sedan::set_theMake(string z){
make = z;
}
int main () {
string zz = "throw error";
Rectangle rect;
rect.set_values (3,4);
cout << "area: " << rect.area() << "\n";
try{
//testing calss Sedan
Sedan bmw;
bmw.set_theMake("BWM 320i");
cout<< "The make: " <<bmw.get_theMake() <<"\n";
throw zz;
}catch(string zz){
cout << zz +"\n";
}catch(...){
cout << "Exception\n";
}
return 0;
}