Difference between Class and Struct.
Answer Posted / kishore
What is the difference between class and structure?
1) 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.
2) structures in c++ doesn't provide data hiding where as a
class provides data hiding
classes support polymorphism, whereas structures don't
3) class and structure are very similar. the former is
heavyweight while the latter is light weight. reference to
the former rests on the heap..while the latter in whole
(instance and data) rests on the stack. therefor care
should be taken not to make a struct very heavy else it
overloads the stack causing memory hogging. class needs to
have an instance explicitly created to be used. A struct
doesn't have to be explicitly initiated
Is This Answer Correct ? | 44 Yes | 7 No |
Post New Answer View All Answers
Write a program with dynamically allocation of variable.
What is the correct declaration of main?
Explain what is the benefit of using an enum rather than a #define constant?
Badboy is defined who has ALL the following properties: Does not have a girlfriend and is not married. He is not more than 23 years old. The middle name should be "Singh" The last name should have more than 4 characters. The character 'a' should appear in the last name at least two times. The name of one of his brothers should be "Ram" Write a method: boolean isBadBoy(boolean hasGirlFriend , boolean isMarried, int age , String middleName , String lastName , String[] brotherName); isHaveGirlFriend is true if the person has a girlfriend isMarried is true if the person is married age is the age of the person middleName is the middle name of the person lastName is the last name of the person brotherName is the array of the names of his brothers
What is character set?
What is a null pointer assignment error? What are bus errors, memory faults, and core dumps?
What is the difference between memcpy and memmove?
What is the general form of function in c?
What is union and structure?
What is c language and why we use it?
Tell me the use of bit field in c language?
Write a program to implement queue.
Is c compiled or interpreted?
What is pass by reference in functions?
Q.1 write aprogram to stack using linklist o insert 40 items? Q.2 write a program to implement circular queue with help of linklist?