C++ Starter: I’m still awful

The most awful thing you can do is mistake C or C++ as your typical high-level language where’s everything is managed for you. Sometimes the hours spent in figuring things out can be incredibly rewarding and every little breakthrough I make, while not remarkable in comparison to other people who have been in the grind for far too long; means something to me.

I spent too much time beating around the single question of “when to use references” and “when to use pointers” after I was bit on a really simple problem.

It turns out that my naive thought of passing by reference was okay. Which backfired almost instantly as I needed to pass the whole pointer else the API wouldn’t work correctly. In this case I’m talking about QNetworkAccessManager. I’ll admit I’m still wet behind the ears, even though I get most of the basic concepts things like pointers and references always leaves me scratching my head for a while because I’m not used to care about the lifetime of an object. I think the biggest doubt I have is “why couldn’t I convert the reference back to a pointer as it was before”. Which I tried, but… the errors the compiler threw were alien to me, for now.

Discovery requires experimentation, I’m afraid. I guess this fool here will eventually find an answer to my question, eventually.

And that’s the gist of it. In languages like C or C++ you have to care about the lifetime of objects. A garbage collector won’t be looking out for you if you leave an object be.

I’m okay with struggling; I will keep pushing forward as always. The learning process in this one has been challenging so far; I’m just glad that I keep winning the small battles. Maybe in six months I’ll win the war, who knows?

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.