B
Bhuwan Bhaskar
Hi,
When to use class and when structure in our application?
Thanks,
Bhuwan
When to use class and when structure in our application?
Thanks,
Bhuwan
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Bhuwan said:Hi,
When to use class and when structure in our application?
I almostBhuwan said:When to use class and when structure in our application?
Kevin said:Another consideration is that a class is a reference type while a structure
is a value type. So, if you want to create copies of instances instead of
references when assigning, structures provide a simple way to ensure that
this is done. That is, if you want assignments to default to copies or
values rather than references, use a structure. This is one way to prevent
accidental modification of the data in the original entity.
Andrew Faust said:In addition to what the other responders said. The most common place I use
struct is if I have a function that needs to return more than 1 value. For
example, suppose you had a function that did integer division. You may
want to return a struct that contained both the quotiant and remainder.
--
Andrew Faust
andrew[at]andrewfaust.com
http://www.andrewfaust.com
Bhuwan Bhaskar said:Hi,
When to use class and when structure in our application?
Thanks,
Bhuwan
Kindly explain how a function can return more than one value?
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.