
- Forum
- Programming Talk
- C and C++
- Is this Right
Is this Right
This is a discussion on Is this Right within the C and C++ forums, part of the Programming Talk category; My friend says the below C++ code class sample { protected: sample( ); }; Is the above class constructed in ...
-
Is this Right
My friend says the below C++ code
class sample
{
protected:
sample( );
};
Is the above class constructed in a such way that it’s gets allocated on the stack. Is this true? Kindly update on this idea.
-
Yes the class you have given in the thread is constructed in such a way that it’s gets allocated on the stack. Additional information about the class you have given is it cannot be instantiated. But you can make this class as a friend of another class and then try for instantiation but in that case it would loose the stack structure and would get allocated as a heap. So depending on your requirements go on with the process.

Reply With Quote





