I wanna know the performance difference b/w
sample *s = new sample();
and
sample s;
where sample is a class.
I wanna know the performance difference b/w
sample *s = new sample();
and
sample s;
where sample is a class.
The difference is that dynamic allocation is slower than the other storage durations. How much: It depends. The difference can be completely irrelevant (for example when the code is unused and compiler happens to be smart enough to optimize either away) or so important that dynamic allocation makes it impossible to guarantee a hard dead line.
A bigger problem with dynamic allocation, than the potential performance difference, is that unless you follow very strict conventions, it is very difficult to prove that your program doesn't leak memory, or that it has well defined behaviour.