Explain the difference between stack and heap memory allocation in C++, and how dynamic memory allocation impacts real-time embedded systems.