One import thing is to use gcc 6.3.0 and not the default 4.2. With gcc 6.3.0 you can use many of the more modern C++ patterns from C++11 and C++14.
Apart from that there is no general training or approach. It also strongly depends on what you want to solve in C++.
Do you plan to write your whole project in C++? Or do you want to only write some encapsulated C++ libraries with interfaces to IEC languages (e.g. function blocks)?
I write my whole (large) project in C++. In my opinion there are no real limitations except the old gcc (which will change soon). For many libraries you’ll find example code for C in the documentation.
For best practice i think that guidelines like CERT C++ or MISRA C++ are a good reference. For other problems it would be the best to ask here.
One very notable limitation is that you CANNOT use objects from one task in another task. Each POU (task or dynamic library) has its own heap. If you create an object in 1 task, then use that object elsewhere, it will likely work in simulation, but once you run it on a machine, you can start getting page faults from malloc.
There are workarounds for this, that make the C++ heap thread safe but I don’t think it’s formally supported. Anyone that knows if that has or will changed, please chime in!
We use C++ quite a bit in libraries, but there are some challenges wrt the runtime system and applications. For example, a c++ object cannot interact directly with IO, HMI, etc. To get any information outside a task you have to have structures defined in .typ and .var files.
I really don’t understand why B&R does not offer more support for such a powerful tool as C++ certainly is.
Yes, there are several pages in Help, but the topic definitely deserves more (training?).
Personally, I would like to extend my skills and start with OOP but unfortunately, I’m not young anymore and switching between languages is not as easy as it was :-). And in this case more support could be more than helpful.
I started very timidly but stuck at the very beginning. As an old school programmer, I use to declare PLC variables and types in files (h and C files) and Help suggest there are no differences between C and C++. But there are (error 5882, _GLOBAL, _LOCAL enabled). So, I ended very disappointed.
Learning an object-oriented programming language like C++ requires not only instructions but also a lot of practical practice.
It is therefore obvious that this cannot simply be integrated into, for example, a 2-day training course.
The Automation Help explains to C++ users the specific things that need to be taken into account when using C++ on a B&R system.
see posting by Tyler Matijevich: Best Practice C++ - #4 by tmatijevich
In order to learn C++ from scratch, there are many learning contents and training programs that support you.
Here are a few links to online courses / vendors who can offer that: