We have been working very hard since 2009 to facilitate in your learning Read More. We can't keep up without your support. Donate Now.

www.bit.ly/vucodes

+ Link For Assignments, GDBs & Online Quizzes Solution

www.bit.ly/papersvu

+ Link For Past Papers, Solved MCQs, Short Notes & More

Looking for Something at Site? Search Below
Structures and Classes are very important data structures used in C / C++. You as a programmer has a choice to use any of them 
as Structures and Classes do provide features some what similar but only with some differences. Now you are given a task 
to code either using Structures or Classes. 
Please give your justification in favor or against of any one you will use for coding.


+ http://bit.ly/vucodes (Link for Assignments, GDBs & Online Quizzes Solution)

+ http://bit.ly/papersvu (Link for Past Papers, Solved MCQs, Short Notes & More)

+ Click Here to Search (Looking For something at vustudents.ning.com?)

+ Click Here To Join (Our facebook study Group)


Views: 328

Replies to This Discussion

use classes in coding due to the following characteristics.
Structures has only data variables gathered, grouped and named as a single entity, but in classes there are both data members and as well as functions to manipulate data members.
In structures data variables are by default public and are visible to all and every one can change them. But the data members and member functions are by default are private and are not visible to every one. In classed we can make the member functions public to manipulate the data members so these are visible to every one and by making data members private we can hide them. So one cannot change the values wrongly.
The only difference between a classes and a structures in C++ is that structures have default public members and bases and classes have default private members and bases. Both classes and structures can have a mixture of public and private members, can use inheritance, and can have member functions.
I would recommend using structures as plain-old-data structures without any class-like features, and using classes as aggregate data structures with private data and member functions.

Read more: CS-201 GDB Full Solution - Virtual University of Pakistan http://vustudents.ning.com/group/cs201introductiontoprogramming/for...

I use structures only when I need to hold some data without any member functions associated to it (to operate on the member data) and to access the data variables directly.

For example:

1. Reading/Writing data from files and socket streams etc.

2. Passing function arguments in a structure where the function arguments are too many and function syntax looks too lengthy.

Technically there is no big difference between classes and strutures except default accessibility. More over it depends on programming style how we use it.



Read more: CS-201 GDB Full Solution - Virtual University of Pakistan http://vustudents.ning.com/group/cs201introductiontoprogramming/for...
Solution post by Muhammad Shafiq Mughal . Gud Muhammad Shafiq Mughal keep it up 

 All don't just copy paste.Otherwise all will be get zero marks this is just idea solution.

Structures and Classes are very important data structures used in C / C++. You as a programmer has a choice to use any of them as Structures and Classes do provide features some what similar but only with some differences. Now you are given a task to code either using Structures or Classes. Please give your justification in favor or against of any one you will use for coding.

 

Your opinion should be concrete with justification in 5 -7 lines only. 

While giving your opinion in favor or against don’t write detailed pages or paragraphs as it is discourage your answer should be to the point.  

 

 

 

 

ANSWER:

 

                Classes are better then the Structures because we can also write the pvt data in it, So by using classes we can hide over data, which I don’t want to share any body. Every thing decleared inside the structure is Public. Classes consist of and are composed from structural and also behavioral constituents. only use structs for POD types, and for add any methods at all, use classes. Use a struct instead of a class is when declaring a functor right before using it in a function call and want to minimize syntax for the sake of clarity.

ONE MORE GDB IDEA SOLUTION OF CS201
I will prefer to use classes in my coding due to the following characteristics.
Structures has only data variables gathered, grouped and named as a single entity, but in classes there are both data members and as well as functions to manipulate data members.
In structures data variables are by default public and are visible to all and every one can change them. But the data members and member functions are by default are private and are not visible to every one. In classed we can make the member functions public to manipulate the data members so these are visible to every one and by making data members private we can hide them. So one cannot change the values wrongly.

RSS

HELP SUPPORT

This is a member-supported website. Your contribution is greatly appreciated!

© 2020   Created by +M.Tariq Malik.   Powered by

Promote Us  |  Report an Issue  |  Privacy Policy  |  Terms of Service

.