+ 4
This is simply done to increase code visiblility and improve compilation, versatility and speed... Also, this helps us to use the class and its members and objects in different areas where needed... The declaration we put in MyClass.h makes it a custom header like iostream, and that header can now be used anywhere as we want. The same code will work if you put the class in the same program where you use it, but that will not allow you to use it anywhere very quickly.. Thus, for classes like Matrix Class, Complex Number Class, etc. , it is better to use a header to make it available for all future c++ files you create...
31st Mar 2017, 12:37 PM
Kinshuk Vasisht
Kinshuk Vasisht - avatar