What Are The Differences Between A C++ Struct And C++ Class?

Answer Posted / shalesh kumar

The default member and base-class access specifies are different.

This is one of the commonly misunderstood aspects of C++. Believe it or not, many programmers think that a C++ struct is just like a C struct, while a C++ class has inheritance, access specifies, member functions, overloaded operators, and so on. Actually, the C++ struct has all the features of the class. The only differences are that a struct defaults to public member access and public base-class inheritance, and a class defaults to the private access specified and private base-class inheritance.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are function prototypes?

823


What are smart pointers?

776


What data encapsulation is in c++?

674


Is c++ a low level language?

603


What is ifstream c++?

660






What are the advantages and disadvantages of B-star trees over Binary trees?

632


Is string data type in c++?

682


What is a type library?

780


How do you add an element to a set in c++?

643


How does a copy constructor differs from an overloaded assignment operator?

667


What is the iunknown interface?

772


Write about the retrieval of n number of objects during the process of delete[]p?

661


Write a program which employs Recursion

856


What are stacks? Give an example where they are useful.

671


What is a unnitialised pointer?

648