What is the difference between Class and Structure?
Answer Posted / uppu goutami
In C++, A structure can have both variable and functions as members.It can also declare some of its members as 'private' so that they cannot be accessed directly by the external functions.
In C++, The structure names are stand-alone and can be used like any other type names. That is, the keyword 'struct' can be omitted in the declaration of structure variable.
For example, We can declare the student variable.
For student A; // c++ declaration
This is an error in C.
C++ incorporates all these extensions in another user-defined type known as 'class'. There is very little syntactical difference between class and structure in C++ and, therefore, They can be used interchangeably with minor modifications. Since 'class' is a specially introduced data type, most of the C++ programmers tend to use the structures for holding only data, and classes to hold both the data and functions.
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What are shallow and deep copy?
Difference between a copy constructor and an assignment operator.
What is stl containers in c++?
what you know about c++?
Is vector a class in c++?
Define copy constructor.
Write a program to find the Factorial of a number
write asingle linked list which read from two list & the do the following 1 sort the prime & nonprime num (prime should be less tn nonprime) 2 each node has a prime num followd by nonprime 3 add a new node into its sutable plce 4 erase the most three duplicated non prime num 5 find the least duplicated prime num
What is abstraction c++?
Define a constructor - what it is and how it might be called (2 methods)?
Should the this pointer can be used in the constructor?
Why should you learn c++?
Which software is used to run c++ program?
What is pointer to member?
How do I exit turbo c++?