Monday, October 14, 2013

Week of October 13

This week we had our first test in Object-Oriented Programming.It counts for about 25% of our total grade.I thought that the time allowed was adequate, and I had time to check my answers.In fact, I found a few mistakes, so I was grateful for the time allotment.In addition, the test questions correlated well with the material presented in class.



Many of the questions on the test were similar to a recent quiz, in which we were asked to identify the constructors or destructors called by various declarations.A class was created (called A) that prints a message when a constructor is called.For example, if the default constructor is called, A() gets printed, copy constructor, A(A) gets printed, etc.There were around 8 questions of this type on the test.In our study group, we prepared for this type of question by plugging the code from the quiz into compileonline.com and trying various scenarios.




One interesting scenario is if you call the constructor for vector with only a size, like vector x(5).It would be natural to expect the output to be A() A() A() A() A().In fact, in C++11, that's what you get.But the implementation of vector's constructor was a bit different in the previous version, so the output is A() A(A) A(A) A(A) A(A) A(A) ~A().It's actually creating a default constructed A, copying it 5 times, then destroying the default A.The short explanation is that the same constructor was called whether you wrote vector x(5) or vector x(5, v), where v is an A to be copied.The code for the constructor included a default A() to be used if you didn't specify the v.In the latest version (at least in the g++ implementation), a separate overloaded constructor was added to handle the case when only a size is provided.This would seem to be slightly more efficient.



On Wednesday we had a guest speaker from NASA's Jet Propulsion Laboratory.We learned how JPL actually doesn't do any jet propulsion research.Rather, they handle NASA's robotic missions to other planets.Our speaker had some great insights into software development in a team environment, and it was exciting learning about internship opportunities at NASA.I couldn't help but think how my wife would have loved this presentation when we were in college originally.She's a computer engineer and was a member of a robotics team that participated in several competitions.Her dream was to work for NASA, but I don't think she was aware of internship opportunities at the time.The story has a happy ending, however, as she wound up developing ASICs at IBM.
Full Post

No comments:

Post a Comment