What is the difference between Class and Structure?

Answer Posted / navin

Structure: Initially (in C) a structure was used to bundle
different type of data types together to perform a
particular functionality. But C++ extended the structure to
contain functions also. The major difference is that all
declarations inside a structure are by default public.
Class: Class is a successor of Structure. By default all
the members inside the class are private.

Is This Answer Correct ?    182 Yes 55 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is stream and its types in c++?

552


write a c++ program to create class student having datamember name,Roll_no,age,and branch intilcization all the member using constructor print the all the details on the screen.

2243


How can we access protected and private members of a class?

585


Can you help me with this one? Make a program that when a user inputed a Product Name, it will display its price, and when the user inputed the quantity of the inputed product, it will show its total price. The output must be like this: Product Name: Price: Quantity: Total Price: ..this is the list of products to be inputed: Cellphone - 1500 Washing Machine - 5200 Television - 6000 Refrigirator - 8000 Oven - 2000 Computer - 11000 thanks..:D

3047


What are the various compound assignment operators in c++?

544






Explain what is polymorphism in c++?

621


What is format for defining a structure?

582


Does there exist any way to make the command line arguments available to other functions without passing them as arguments to the function?

737


What are arithmetic operators?

531


Why c++ does not have finally?

585


Write about the access privileges in c++ and also mention about its default access level?

612


What is the standard template library (stl)?

616


What is an accessor in c++?

616


Differences between private, protected and public and give examples.

575


Explain static and dynamic memory allocation with an example each.

638