Finish cleanup of Assignment 6, complete of Rust, and most of 396's assignments.

This commit is contained in:
Charles Descamps 2024-11-25 01:05:10 -07:00
parent 5bdbe09523
commit 70d1cf9b35
8 changed files with 371 additions and 152 deletions

View file

@ -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;
}