Saturday, 14 September 2013

Add a method to existing C++ class in other file

Add a method to existing C++ class in other file

Is it possible in C++ to extend a class(add a method) in different source
file without editing the original source file where the class is written?
In obj-c it is possible by writing another @interface AbcClass
(ExtCategory) ... @end
I got compile-time error when I tried these:
//Abc.h
class Abc {
void methodOne();
void methodTwo();
}
//Abc+Ext.h
class Abc { // ERROR: Redefinition of 'Abc'
void methodAdded();
}

No comments:

Post a Comment