CSE 250 Spring 2011
Due Date: Feb 28, Monday, by 2:05pm
Total Points: 25
does swap the values of the array elements
when they are in bounds. If one or both
of them is out of bounds,
will still try to change those locations in memory, which may result
in a segmentation fault, or just erroneous values being swapped into the valid region of memory for
SIZE] = 5;
is indexing out of bounds, which may result in a run-time error
(Segmentation Fault), but may instead execute and overwrite some other variable leading to
strange behavior or data.
x[n] = 10/n;
would throw an Arithmetic Exception run-time error if it followed the
previous line (
int n = 0;
), because you’d be trying to divide by 0.
- Declares a Computer object.
Computer c2(‘‘Ace’’,‘‘AMD Athlon 2000’’, 512, 60);
- Declares and instantiates a Computer
object, using the constructor to set the data ﬁelds to the speciﬁed parameters.
Top c3(‘‘Ace’’,‘‘AMD Athlon 2000’’, 512, 60);
- This is an invalid statement and will not
Top class only has one constructor, which requires two more arguments than the Computer
Top c4(‘‘Ace’’,‘‘AMD Athlon 2000’’, 512, 60,15.5, 7.5);
- Declares and instantiates a
cout << c2.manufacturer << ", " << c2.processor << endl;
- Compilation Error, manufac-
turer and processor are private variables.
cout << c2.get