Click here to Skip to main content
15,884,995 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
This question arrives in my mind because when i work on OOP and use the classes then i see that we use the keyword 'class' for making a class in our program
But my question is,if we write 'struct' instead of 'class' and no more change we do then the program works
even if we use constructor,destructor,access specifiers etc the compiler did not show an error
So why we use classes and create objects ???

What I have tried:

And also i want to know that why we use OOP instead of structured programming which is too simple to write and understand and we don't need to work extra on making classes and others
Posted
Updated 21-Jun-18 10:12am

In C++ classes and structs are more or less the same. See the previous link I gave you for a full explanation.
 
Share this answer
 
Comments
Member 13881359 22-Jun-18 0:03am    
Thanks a lot sir
Some insight here: The real difference between struct and class[^].



Quote:
And also i want to know that why we use OOP instead of structured programming which is too simple to write and understand and we don't need to work extra on making classes and others
C++ is a multi paradigm language, if like, you may use it as a 'better C', following structured programming principles. In my opinion OOP has its advantages, expecially on big projects.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900