Example: Thread::Thread
:
class Thread
{
Process * parent_;
unsigned __int32 id_;
void * entryPoint_;
public:
Thread(Process * parent, unsigned __int32 id, void * entryPoint) :
parent_(parent),
id_(id),
entryPoint_(entryPoint)
{
}
unsigned __int32 GetId() const
{
return id_;
}
void * GetEntryPointAddress() const
{
return entryPoint_;
}
};
I can't seem to come up with a way of indenting things so that it doesn't look strange... and yet this is a common pattern. What are common ways of indenting this?
I always put empty blocks on a single line – i.e. { }
(notice the space!).
Furthermore, I usually put the colon and commas in front of the initialization list members instead of after – this makes adding members later on easier.
Thread(Process * parent, unsigned __int32 id, void * entryPoint)
: parent_(parent)
, id_(id)
, entryPoint_(entryPoint)
{ }
(Edit: I no longer follow this style myself: I omit the space between braces nowadays.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With