<p>What are some C++ related idioms, misconceptions, and gotchas that you've learnt from experience?</p>

<p>An example:</p>

<pre><code>class A
{
  public: 
  char s[1024];
  char *p;

  A::A()
  {
    p = s;
  }

  void changeS() const
  {
    p[0] = 'a';
  }

};
</code></pre>

<p>Even know changeS is a const member function, it is changing the value of the object.  So a const member function only means that it will treat all variables as const, and it does not mean that it will actually keep all members const.  (why? the const keyword on the member function treats char *p;  as char * const p;  And not as const char *p;</p>

<p>Which therefore means that p can't point to something else.   And not that you can't change p's data.  </p>

I've liked this since the time i've discovered it in some code:
```
```
assert(condition || !"Something has gone wrong!");
```
```
or if you don't have a condition at hand, you can just do
```
```
assert(!"Something has gone wrong!");
```
```
The following is attributed to
@Josh
(see comments). It uses the
comma operator
instead:
```
```
assert(("Something has gone wrong!", condition));
```
```