Exforsys
+ Reply to Thread
Results 1 to 2 of 2

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 ...

  1. #1
    ashlee is offline Senior Member Array
    Join Date
    Apr 2006
    Answers
    108

    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.


  2. #2
    caradoc is offline Senior Member Array
    Join Date
    Apr 2006
    Answers
    122
    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.


Latest Article

Network Security Risk Assessment and Measurement

Read More...