This is the home page for CS253, Problem Solving with C++,
a CSU Computer Science class.
Click on the links, above, for other class pages.
#include guards.
HW3 is now due one week later, on March 13.
HW3 is now available.
I just sent the following to my teaching assistants:
As you recall, there was a question about copy ctors on the midterm:
class Whatever. Yes, the declaration.
The best answer is:
Whatever(const Whatever &); // pass argument by const reference
This answer, which will fail if trying to copy a const object, is also acceptable:
Whatever(Whatever &); // pass argument by non-const reference
Then there’s this answer. This is invalid C++ (see below), but, because I incorrectly stated in class that it’s valid, this should also be granted points for Midterm #1 only. If a student comes to you with the following, they should get a point for it:
Whatever(Whatever); // pass argument by value (INVALID C++)
In all cases, it’s also acceptable to put in a variable name:
Whatever(const Whatever &w); // pass argument by const reference
Whatever(Whatever &w); // pass argument by non-const reference
Whatever(Whatever w); // pass argument by value (INVALID C++)
Why is the third one invalid? It seems reasonable, at first: we want to pass the argument by value. Just copy the actual parameter, from the calling code, to the formal parameter w. Wait--copy? How do you copy an object? You call the copy constructor. But this is the copy constructor! We can’t call the copy ctor from the copy ctor—that’s infinite recursion. That’s why we must use a reference.
That’s why the third one is invalid C++, and will not compile. But we shouldn’t punish the students for my error, so they get a point for it.
The last question on the midterm was:
There are two answers:
My office hours will actually be in my office, CSB 246, Monday February 25 and Tuesday February 26.
HW2 scores are available: ~cs253/bin/grade HW2
Specify HW2 to get detailed feedback.
Q1 has been curved. ~cs253/bin/grade
The HW2 writeup has been improved after today’s class, with many clarifications.
HW2 is now available.
HW1 has been graded. For detailed information:
~cs253/bin/grade HW1
My read-only solution to HW1 is available here.
HW1 is now available.
Please, no onions in the Computer Science Building, including the Linux Lab. One of our faculty has a severe allergy.
Recitation (lab) the first week is optional. Attend if you need help logging in, editing files, using g++, or general help with HW0. If your recitation was Monday, then you may attend one of the other recitations (see the syllabus) this week.
If I clarify an assignment, change a due date due to weather, etc., I’ll announce it here.