Jump to content
Sign in to follow this  
  • entries
  • comments
  • views

C++ and C# class differences

Sign in to follow this  


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#.
Sign in to follow this  


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!