What is the difference between structure and class?



What is the difference between structure and class?..

Answer / Prashantkumar

In C++, both structures (struct) and classes are user-defined data types, but they have some differences:nStructures by default have public members and are primarily used for grouping data together. Classes have both public, private, and protected members and provide additional features like inheritance, polymorphism, and encapsulation.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C++ General Interview Questions

What is a string example?

1 Answers  


What is object file? How can you access object file?

1 Answers  


What is scope in c++ with example?

1 Answers  


Write a single instruction that will store an EVEN random integer between 54 and 212 inclusive in the variable myran. (NOTE only generate EVEN random numbers)

1 Answers  


Is c++ vector dynamic?

1 Answers  


What is the difference between while and do while loop? Explain with examples.

1 Answers  


What is a pointer how and when is it used?

1 Answers  


What is name mangling?

3 Answers  


Tell me can a pure virtual function have an implementation?

1 Answers  


When do we run a shell in the unix system? How will you tell which shell you are running?

1 Answers  


Design a program to input a date from user in the form day/month/year (e.g. 2/6/2000) and report whether it’s a valid date or not. The program should take account of leap years. You will need to know that a leap year is a year that is exactly divisible by 4, except that century years are only leap years if they are divisible by 400.

1 Answers  


Differentiate between an array and a list?

1 Answers  


Categories