|
-
January 28th, 2008, 01:58 AM
#1
class...struct...interface...Messed up??
I am a rookie here coming from c++ background. I have been doing a little reading. Dont feel very comfortable with the definition class, struct, & interface. Personally I feel this is messed up quite a bit.
Do let me know your views on the same.
What was need of such an segregation? Coud they have not combined alll the required functionality in one - a class and let the programmer decide how to go about it. Dosent that make more sense rather than...
****************************************************************************************
1. Class is reference type
2. Struct is value type
and
3. new is used to allocate objects on the heap
 Originally Posted by MSDN
In C#, the new keyword can be used as an operator or as a modifier.
- new operator Used to create objects on the heap and invoke constructors.
BUT--->
Although new is an operator used to allocate objects on the heap
Code:
SomeStruct obj = new SomeStruct();
This new creates an object on the stack since its "value type" 
****************************************************************************************
1. Does it not make sense to have class defined as having x, y, z characterstics, and let the programmer decide, when he wants it on the stack and when on the heap.
2. Now considering (1) where is the need of a struct?
3. Interface.
My initial impression of interface is that it could cause some serious design problems making u to fall back on a class at times. If i am right about this, again comes back to we cud have done with just a class with the functionality combined in one.
Kindly let me know ur views on the same
Last edited by ChessMaster; January 28th, 2008 at 02:21 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|