Install this theme
EXPLANATION. Calling member function on null object in C++

olsterscoding:

Usually when you call a function on null object, a program crashes. But if it doesn ‘t reference any member variables, the function will be called and the program won’t crash.

Read More

The app doesn’t crash because of the C++ member function calling convention. Internally, member functions are marked as __thiscall. That means that the object that’s calling the function is passed as its parameter.

For instance,

Foo obj;
obj.DoStuff(params);

Translates into something like:
Foo obj;
Foo::DoStuff(&obj, params);

That &obj part is treated like this pointer inside the function.

So as long as you’re not dereferencing this, you’re all good!


Calling member function on null object in C++

Usually when you call a function on null object, a program crashes. But if it doesn ‘t reference any member variables, the function will be called and the program won’t crash.

Read More



Windows services in C++

Not too long ago I had to write a Windows service in C++. Now, C# has a template for that that one can use and write a service quickly. But C++? Yeah, you have to build that one up from the ground.

Inspired by C# ServiceBase class, I created my own C++ ServiceBase class that helped me quickly write a service that would track users logging on and off the system, as well as locking/unlocking the PC.

Link to GitHub repo


kr-studios:

kr-studios:

The benefit of C++ is that you can fall back to C style coding. i.e. instead of using loops & the new/delete operators, I’m just going to use malloc() & free().

Oh, calloc() is a thing.

realloc() is a thing too.

But that doesn’t mean that you have to use C functions in C++ if you want to allocate memory without calling a constructor. void ::operator new(size_t size) is still a thing, you know.

And C++ has a placement new, which is a great thing for memory pools.


the-analytical-engine:

Lecture 3 - Algorithms & Analysis: Brute Force

Copyright 2013 RMIT - Shane Culpepper


Note to self: Learn to focus on important things.


what-if-i-just-shat-myself:

pool party!!! more like thread pool party haha am i right

I’ll invite you to my memory pool party!


The thing about programming is that no matter what your level of experience might be, an elusive bug can still bring you to your knees in a sobbing fit.
(via thethingaboutprogramming)

YES THIS

(via cjbrowne)

That was fun, Google

That was fun, Google