C++ and C# class differences

Published December 29, 2007
Advertisement
The capability of extending the class declaration/definitions across different files, is a good feature. There are times when even the C++ class declarations are too large for one page, due to the overloads and helper functions (though infrequent occurrences). However, I have issue with the limits with the partial keyword usages. The most annoying limit is for a partial function must return void. The functionality in C++ to separate the declaration and definition is an important one. The user of the class does not have to see the implementation, nor should they. Also, it makes the complete class operations and attributes readily apparent to the developer. In C#, the only way to do this is to treat the class as a partial class, then re-declare the class somewhere else and fill in the implementation. How it should be, is to declare the class, with no limitations on separation of declaration and implementation, then fill in the details elsewhere by calling the proper membership:

class MyClass
{
public int attribute1;
private bool attribute2;

public bool SomeBoolFunction();
private int SomeIntFunction(ref AnotherClass arg);
}

// Elsewhere in another file, or below the declaration:
bool MyClass.SomeBoolFunction()
{
bool temp;
// Funtion details
return temp;
}

int MyClass.SomeIntFunction(ref AnotherClass arg)
{
int temp;
// Function details
return temp;
}

This structuring ability works extremely well in C++, why take this ability away in C#? For a company which prides itself on hiring the brightest, sometimes, they make the dumbest decisions. Just me venting. I guess I am not yet "use to" C#.
Previous Entry Starting with XNA
0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement

Latest Entries

Advertisement