What is the difference between Class and Structure?

Answer Posted / mohanraj.d

1.structure is a value type.but class is a reference type.
2.structure is stored in stack.but class is stored in heap.
3.struct cannot have default constructor.
4.struct do not support inheritance.
5.class can inherit from a class.
6.struct cannot have declare destructor.
7.class has define object and function.
8.structure has define only object.

Is This Answer Correct ?    50 Yes 28 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is python written in c or c++?

614


What is a volatile variable in c++?

556


Explain overriding.

600


What is an orthogonal base class in c++?

648


How many different levels of pointers are there?

652






Describe linked list using C++ with an example.

641


What is dev c++ used for?

603


Given the following seqment of code containing a group of nested if instructions: y = 9; if ((x==3) || (x == 5)) y++; else if (x == 2) y *= 2; else if (x == ) y-= 7; else y = 8; if the value of x is 4 before the nested IFs are executed, what is the value of y after the nested IFs are executed?

1576


Write a recursive program to calculate factorial in c++.

605


Can you pass a vector to a function?

532


Do we have to use initialization list in spite of the assignment in constructors?

561


Why ctype h is used in c++?

519


What is == in programming?

610


write a program that reads in a file and counts the number of lines, words, and characters. Your program should ask the user to input a filename. Open the file and report an error if the file does not exist or cannot be opened for some other reason. Then read in the contents of the file and count the number of lines, words, and characters in the file. Also print additional information about the file, such as the longest and shortest words, and longest and shortest lines. For simplicity, we define a word to be one or more characters ending with white space (a space, tab, carriage return, etc.). Functions for checking the types of characters can be found in the ctype.h header file, so you want to include this header file in your program. For example, the sentence below could be all that is in a file. This sentence IT 104 is taught in C++. has 32 characters, one line, and six words. The shortest line is 32 characters. The longest line is 32 characters. The shortest word is 2 characters. The longest word is 6 characters

4847


Write a struct time where integer m, h, s are its members?

513