From a49760dde683c9751af19c8f8aa0c2569bab6024 Mon Sep 17 00:00:00 2001 From: Ralph Tandetzky Date: Sat, 7 Mar 2015 20:46:00 +0100 Subject: [PATCH] Gave explanation for 'assert' and use of templates. --- 03-Style.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/03-Style.md b/03-Style.md index 2f5a03e..ab60aaa 100644 --- a/03-Style.md +++ b/03-Style.md @@ -282,9 +282,11 @@ assert(registerSomeThing()); // make sure that registerSomeThing() returns true ``` The above code succeeds when making a debug build, but gets removed by the compiler when making a release build, giving you different behavior between debug and release builds. +This is because `assert()` is a macro which expands to nothing in release mode. ## Don't be afraid of templates They can help you stick to DRY principles. +They should be preferred to macros, because macros do not honor namespaces, etc. ## Use operator overloads judiciously