Private? The false assurances of C++

Yet another reason I believe that C++ is the wrong language for teaching introductory programming. Because of the way classes are laid out in memory, it is trivial to show (a good thing), but it is also trivial to access those private member variables directly.

TLDR? – View the gist on github

Let’s break this down. We have a class called Point


The point class in this instance represents a 2D and has the private member variables of x and y.


If we have, say, a local variable (Point p;) we can do some basic calculations. This may be compiler / OS / architecture dependent, but this works in 32-bit linux w/ gcc on i386.


When we run this code, we see that the sizeof(point) is identical to the sizeof(int) + sizeof(int). Since classes in C++ are based on structs in C. This is just a tight packing of the member variables.

And if the base pointer for &p is 0xa43c then we see that the address of x is the same, and y is off by 4 bytes (the size of an int).

Now – if we just try to access the private member variable directly, i.e. p.x = 27; the compiler will detect that we’re trying to do something bad and give us an error (good!).

However, through the magic of memory addresses and pointers we can change that. It is a simple cast. First we get a pointer to our instance of the Point class, and then we re-interpret that as a pointer to an int. From there we can start derferencing and using pointer math.


That’s it. A simple cast and some pointer math and private doesn’t mean anything. Who needs encapsulation anyway?

I got my license!

I almost feel like I’m 16 again… well, not quite.

As you already know, I passed my written test on Saturday. On Sunday, I passed my riding test as well! I did get 6 points off. I anticipated the quick stop (started breaking before the cones), but nailed it on the second try. And I got 1 point off for cornering a little too slow. The scooter riding was a lot of fun, but I am looking forward to getting out on to the road. Riding around a parking lot is a little limited, I only got to 20 or 25 Mph.

I called my insurance agent today, and the insurance on a scooter is only $100 to $140 a year, so that is good. Insurance isn’t required on motorcycles in WA, but you’d have to be crazy to ride without it, especially when it is that cheap.

Tomorrow morning I am going to the department of licensing office to actually get my new license. (I just got a test waiver card after the class).

I’m also going to call the local Vespa dealer tomorrow and see if they have the scooter I want in stock. I was planning on waiting until Saturday to purchase, but since our tax refund arrived ahead of schedule, I will be scootering sooner!

We currently have a dry weekend in the forecast, so I should be able to practice riding around the neighborhood. And I will have Cortny take some pictures 🙂

Motorcycle Safety Class

I haven’t had anything to write this week … it was a pretty boring week. I went to work, came home from work, went to yoga a few times.

On Thursday night, I started my motorcycle class. Thursday was all classroom work. This involved reading the course book, discussion, and watching awesome drivers’ ed. videos. Since I had already read the state of Washington guidebook and a scooter specific pamphlet from the Motorcycle Safety Foundation, it was stuff that I had already had time to process.

Today (Saturday) was the real fun! Starting at 8am we actually got to ride the scooters. got there early, so I was able to claim a Vespa LX150 (the same scooter that I intend on buying if I pass the class).

And, well…. scooters are a lot of fun! The Vespa is awesome, easy to drive, easy to maintain balance, and just plain fun. My gear all worked out well. My helmet is comfortable, as are my jacket and gloves.

The skills we went over today – starting, stopping, turning, weaving…. the basics. I feel like I did pretty well. Starting is pretty easy – nice even throttle. Stopping is easy as well, I just need to work on letting off the throttle quicker while I break. The turning is interesting. Leaning into turns is much easier than I thought. Turning at low speeds is actually harder that turning at high speeds (above 10mph). Weaving in and out of cones… that was fun 🙂

After the riding class, we headed back to the classroom. I had read the rest of the manual yesterday, so it was a little slow. We then had to take the written, “knowledge” text. I scored 100% on the written test…woo! Now I just have to pass my skills test tomorrow and I will be able to get my motorcycle endorsement.

Blue Bell Special

Our favorite local restaurant – Hi-Life ( is having a special promotion this winter.

They have a set meal each night (Sunday – Thursday). Each night’s meal is based on the value of the dow at the closing bell. So, for example, tonight we paid $7.56 for great dinner of meatloaf, mashed potatoes, carrots, and onion rings. It really is an incredible dinner, this meal would easily sell $15 – $20 normally.

If you’re in town, we highly recommend Hi-Life for breakfast, lunch, or dinner!

Yep, It’s Tuesday

And that’s about all I have to say. Once we get into the work week, that’s kind of what I do … work.

Yesterday was nice, because of the holiday, the bus was just about empty in the morning (I did not have the day off). It is nice to have a seat to myself 🙂 And of course today, we’re back to standing room only. I have started going to a different bus stop (70th instead of 65th) and that ensures that I always get a seat.

And yes – that is the most exciting thing that has happened so far this week.

I did manage to make it though yoga Monday night. I was a little worried since I was so sore from Sunday’s ski trip, but it wasn’t so bad. I will be resting up tonight, and then back to yoga tomorrow.

That’s all for now.

Up the Mountain, and back Down Again

It took me over a year, but I made to to one of Washington’s fine ski areas today.

We went to Crystal Mountain, a ski area in the Mr. Rainier national park. Normally you can see Mr. Rainier from the area, but not today. There was steady snow falling all day. At the peak (we got up to about 6800 feet), there were very very windy conditions with blowing snow… but it was still way fun.

Having grown up skiing on perfect north …. I felt like I had never skied before. It’s amazing to go to a huge ski resort that relies on nature made snow, and gets a bunch of it. Since the snow was falling, the trees were all frosted, everything looked awesome.

Like my last post, here is someone else’s video. They’re going down one of the runs that I really liked … but today visibility was about 100 yards in front of you at the top.

A Trip to the Vespa Dealer

We took a trip to the vespa dealer today, and it was pretty fun.

I looked at a few models, and in particular looked at the one I am interested in (the LX 150). I didn’t ask to test drive, since I don’t have a motorcycle endorsement on my license yet, but I got to sit on the scooter. It’s a pretty substantial machine, the unibody constructions feels really solid leaning side to side. After I complete the safety course and get the endorsement added to my drivers license, than I can go back and actually get the scooter.

I spent a good bit of time looking at accessories. In order to take the safety class, I need to have a helmet, jacket, and gloves. I didn’t want to get a leather motorcycle jacket, which is good, because they had a bunch of cool scooter jackets.

The jacket: a Corazzo 5.0 : in khaki/red color. It has armor in the shoulders, elbows and a big back pad. The stripes down the front and back are darn reflective, which will help in people seeing me. I also picked up some gloves from the same company:, they’re kevlar and should be good for spring/sumer riding.

The helmet: I ended up getting a Vespa branded helmet, the Piaggio Copter – I went back and forth on full face vs. 3/4 helmet and I ended up getting the one that I felt most comfortable wearing. I imagine that I will pick up a full face helmet at some point, but for now, I felt comfortable wearing the one I purchased.

The folks at Vespa Seattle were very helpful. They explained the scooters to me, answered all my questions, and helped with the gear. It seems like a very good shop. Plus, they’re involved with the motorcycle safety program. The salesman said they provide some of the scooters for the class, so I will likely get to take my class on a Vespa. And, since I was signed up for the class, they gave me 10% off today.

Here is a video of someone else riding a Vespa, up in Victoria, B.C.

Making Ravioli

Today was a long day at work – it was annual review day. I had to write my self review, and 4 peer reviews. I also got to spend some time working with a customer, and that’s always fun.

I thought yoga would be a good way to wrap up the day, so I went to the 5:30 level 2-3 (Cortny stayed home). It worked! I’m certainly not thinking about work anymore because I’m so tired 🙂

After yoga, Cortny and I made homemade ravioli. We do a lot of team cooking. I made the dough and rolled out the pasta sheets. While I was doing that, Cortny made the fillings. She made a ricotta and parsely filling as well as a mashed potato filling. Ever since we were in Italy, we’ve been want to have potato filled ravioli again. We had some in Florance, and it was the most wonderful thing ever, seriously.

The ravioli is all for tomorrow night’s wine tasting. We still have a little bit of getting ready to do. I am going to drop the puppies off at the dog lounge in the morning so that Cortny can clean up the house, and she is also going to make the sauce.

So – tomorrow should be fun 🙂

Also this week, both of my siblings bought houses this week. Congratulations to them, especially brother Dan who bought is first place.

Deathcake Royale

This is something we missed last year – well not this year! Our local cupcake place ( offers the “Deathcake Royale” at this time every year.

We put in an order for 10 (we are hosting a wine tasting on Friday), so we will get to try it soon. Very exciting 🙂 Seattle Magazine reviewed the cupcake.

Following on – we are hosting a wine tasting on Friday night, all Chianti. We picked up a well rated bottle at our local wine bar – Portalis ( Incidentally, Portalis is just a fun place to hang out, we had a bottle of wine there last Saturday.

Since the wine is Chianti, we are preparing to make some yummy Italian treats. We’ll be making homemade ravioli and homemade sauce. There will be both cheese filled and mashed potato filled ravioli (yummy!).

So that’s all – we’re heading to yoga soon to pre-burn the calories that we are going to consume on Friday night.