Are there extensions for C++ like there are in C#?
For example in C# you can do:
public static uint SwapEndian(this uint value)
{
var tmp = BitConverter.GetBytes(value);
Array.Reverse(tmp);
return BitConverter.ToUInt32(tmp, 0);
}
someuint.SwapEndian();
Is there anything like that in C++?
The function of extension is to bring about desirable changes in human behaviour by means of education. Changes may be brought about in their knowledge, skill, attitude, understanding, goals, action and confidence. Change in knowledge means change in what people know.
6 Extensions to the C Language Family.
Extension Methods in C# An extension method allows you to add functionality to an existing type without modifying the original type or creating a derived type (and without needing to recompile the code containing the type that is extended.)
There are no extension functions in C++. You can just define them as free functions.
uint SwapEndian(uint value){ ... }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With