To kill a singleton: I found this to be a useful discussion on how to write a singleton class in C++ that ensures the singleton is properly destroyed (for even multithreaded applications).
You are currently browsing the archive for the Computing category.
“Sydney Mail is a new and significantly improved student email service,” announced the email from the university proudly.
The truth is that the university has delivered something that’s better, but is rather deficient in its own right: they’ve outsourced email to Microsoft so it’s all now run off Outlook Web Access. I could go on and on about why I would never use it, but I’ll just show you how to avoid using it.
The existing email system allows you to forward to a personal email address, and the university provides instructions for how to do it on the new system. Don’t follow those instructions! It is true that email will be forwarded from Outlook to your personal email but what happens is that the emails are literally forwarded! If Bob sends you an email, when it pops up in your personal email, the From field will show your university email as opposed to Bob, which is incredibly inconvenient.
The solution? Get your mail client to retrieve mail from Outlook via POP3. If you’re using Gmail like me, go to Settings > Accounts. Look for the “Get mail from other accounts” section and click the “Add a mail account you own” link. A window will then pop up; try the following settings:
Email sent to your university email won’t get forwarded instantly like it used to, but it’s a much better solution than the one offered by the university.
Here are the solutions to the C++ maps exercise I posed in this post.
The first set of problems relates to the fact that the Employee class has no default constructor. Here’s why. In the line
id = Employee("John Smith");
what doesn’t happen is that the key 0 gets associated with the new Employee object you just created. What does happen is that the
id part tries to default initialise an Employee object, and then assign using
operator= the Employee object you created on the right hand side. That’s all fine if you have a default constructor, but our Employee class doesn’t have one (because I’ve defined another constructor but not the default constructor). Without changing the class definition to add a default constructor, you will need to explicitly insert the key-value pair into the map, like this:
id.insert(make_pair(0, Employee("John Smith")));
But what about this line?
cout << id.name << endl;
Surely, it wouldn't be trying to call the default constructor here, because I am merely retrieving the value of
id, which I know has already been constructed? But at compile time, how would the compiler know whether the call to
id will result in a new object being constructed or not even if you do? To get around this problem, you'll have to go around the long way:
cout << id.find(0)->second.name << endl;
So the moral of the story is write a default constructor (if it makes sense to do so)! Note that
operator is also unavailable when you have a const map. (Why?)
For the second lot of problems, the root of the problem is that you are using Employee as the key type of the map. You can only use a class as a key if you can order objects of that class, so you'll have to write an
operator< for Employee.
Why doesn’t the following code compile? Without changing the definition of the struct Employee, can you make it compile so that it does what it’s meant to do?
(I gave this exercise to my C++ students a couple of weeks ago.)
Lenovo wins $150m NSW schools deal: It’s great to see the NSW government giving form to the “digital revolution” by providing laptops to schoolchildren, but the dominance of Microsoft and Adobe software denies NSW kids the chance to see beyond the Windows straitjacket — and taxpayers more bang for their buck.
To illustrate how to use it, let’s suppose you have a bunch of
.h files in the current directory that you want to print all at once. To pretty-print these files to a printer, consider using:
a2ps -P printer_name *.cc *.h -MA4 -Afill
Cursed computer! No calculator!
I’ve been annoyed by how locked down the computers at Sydney Uni’s libraries are for a while, so I set out to find out whether I can, in fact, bring up the humble calculator.1
My mobile’s battery is flat, so to call my mum to pick me up from the station, I’ve turned on my work laptop, connected to Telstra NextG, connected to VPN using my secure token, logged into Cisco IP Communicator (which emulates the IP phones we have on our desks at work) and then made a call using that. That’s pretty cool (but not quite as cool as this).
An open source, standards compliant CMS from Microsoft? That sure is trippy enough to deserve a smiling mushroom high up in an aeroplane.