On Saturday, 18 February 2017 13:06:55 UTC+2, JiiPee wrote:
> I use this a lot but just dont know (even after reading about patterns)
> which pattern it is. Surely a simple question..
>
> Can somebody help me please, what pattern is this when you can add a
> different behaviour by pointer member variable:
snip
>
> void main()
That is called "flame bait" pattern. Posting code with "void main"
in it gets flames in both comp.lang.c and comp.lang.c++ and so livens up
discussions there.
> {
> Car car1;
> car1.m_drivingStyle = new DriveErratically();
> car1.drive();
> car1.m_drivingStyle = new DriveNormally();
That is called "memory leak" pattern. It helps the industry to sell more
and bigger RAM to customer computers.
> car1.drive();
> ...
> }