With its implementation of C#, Microsoft have given way to some of C++'s nitty-gritty object-orientated features such as templates, and have also changed the way we create classes. In this article, Jordan compares and contrasts classes in both C++ and C#. He focuses on demonstrating how Microsoft has changed certain aspects of creating and using classes in C# including reference types, virtual functions and polymorphism.
Object-orientated programming has taken us a long way in terms of application design and development in the last twenty or so years. A program is no longer thought of as a series of functions, which are executed in sequence (like in the procedural programming paradigm), but rather as a set of objects where each object exposes certain properties and methods allowing it to interact with other objects.
The "C" series of languages is a great example of how Object-orientated design disciplines have evolved over time. C++ provides developers with an excellent implementation of object-orientated programming, allowing them to explicitly create constructors, copy constructors, override operators, use templates, etc.
The main problem with a complex language like C++ is that it takes several months to truly master its object-orientated design nature, with each new programmer having to come to grips with templates, function overloading and of course sensible class creation and usage.
With its implementation of C# (pronounced C-Sharp), Microsoft have given way to some of C++’s nitty-gritty object-orientated features such as templates, and have also changed the way we create classes. In this article, I'm going to compare and contrast classes in both C++ and C#. I will also focus on demonstrating how Microsoft has changed certain aspects of creating and using classes in C#.
This article was written for fluent C++ programmers looking for some common ground when trying to learn C# and its object-orientated capabilities from scratch.