Finish cleanup of Assignment 6, complete of Rust, and most of 396's assignments.
This commit is contained in:
parent
5bdbe09523
commit
70d1cf9b35
8 changed files with 371 additions and 152 deletions
|
|
@ -10,33 +10,21 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
class A
|
||||
{
|
||||
int i;
|
||||
|
||||
public:
|
||||
A(int ii = 0) : i(ii) {}
|
||||
void show() { cout << i << endl; }
|
||||
};
|
||||
|
||||
class B
|
||||
{
|
||||
int x;
|
||||
|
||||
public:
|
||||
B(int xx) : x(xx) {}
|
||||
operator A() const { return A(x); }
|
||||
};
|
||||
|
||||
void g(A a)
|
||||
{
|
||||
a.show();
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
B b(10);
|
||||
g(b);
|
||||
g(20);
|
||||
int wait_time = 46;
|
||||
try
|
||||
{
|
||||
cout << "Try block entered.\n";
|
||||
if (wait_time > 30)
|
||||
throw wait_time;
|
||||
cout << "Leaving try block.\n";
|
||||
}
|
||||
catch (int thrown_value)
|
||||
{
|
||||
cout << "Exception thrown with\n"
|
||||
<< "wait_time equal to " << thrown_value << endl;
|
||||
}
|
||||
cout << "After catch block." << endl;
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue