What is the difference between Class and Structure?

Answer Posted / sundarchum

Structs are Value type. They are stored as a stack on
memory.
Class is reference type. They are stored as heap on memory.
Sturcts constructor must contain a parameter and cannot
have default constructor.
Class constructor may contain no parameter.
Struct cannot have instance field.
Class can have instance field.
Struct cannot inherit from a structure.
Class can inherit from a class.
Structs cannot declare a destructor.

Is This Answer Correct ?    101 Yes 49 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What does new do in c++?

637


Write a program in c++ to print the numbers from n to n2 except 5 and its multiples

2041


Is c++ an integer?

579


How can you quickly find the number of elements stored in a static array?

640


What is the average salary of a c++ programmer?

545






State the difference between pre and post increment/decrement operations.

610


What should main() return in c and c++?

529


Define a conversion constructor?

621


How to give an alternate name to a namespace?

591


Write a program to find the Fibonacci series recursively.

612


What data structure is fastest, on average, for retrieving data: a) Binary Tree b) Hash Table c) Stack

588


Which field is used in c++?

640


What is a multiset c++?

553


Write a program to read the data and evaluate the results of the election. Print all output to the screen. Your output should specify: The total number of votes, the number of valid votes and the number of spoilt votes. The winner(s) of the election. Hint: An appropriate search should be used to determine the winner(s). The votes obtained by each candidate sorted in terms of the number of votes obtained. Hint: An appropriate sort should be used to sort the candidate(s). The Source code should be saved as VotingSystem. Project Input: Candidates’ Names and Numbers 2501 Victor Taylor 2502 Denise Duncan 2503 Kamal Ramdhan 2504 Michael Ali 2505 Anisa Sawh 2506 Carol Khan 2507 Gary Owen Votes 3 1 2 5 4 3 5 3 5 3 2 8 1 6 7 7 3 5 6 9 3 4 7 1 2 4 5 5 1 4 0 Project Output: Invalid vote: 8 Invalid vote: 9 Number of voters: 30 Number of valid votes: 28 Number of spoilt votes: 2 The winner(s): 2503 Kamal Ramdhan 2505 Anisa Sawh Candidate Score 2503 Kamal Ramdhan 6 2505 Anisa Sawh 6 2501 Victor Taylor 4 2504 Michael Ali 4 2502 Denise Duncan 3 2507 Gary Owen 3 2506 Carol Khan 2

2656


Which of the following is evaluated first: a) && b) || c) !

1809