Hi friends,
I recently started learning C++ language. I have written following code in C++. In this code I have use different functions for creating different objects, but I want to create a generic get object function. I don't know how to do this. Can anyone tell me how to create generic get object function in c++?
Code:
class bases {
} ;
class bases1 {
} ;
bases* getBases(void) {
bases *retVals = NULL ;
try {
retVals = new bases ;
} catch(bads_allocs &faileds) {
cerr<<faileds.whats() ;
exit(-1) ;
}
}
bases1* getBases1(void) {
bases1 *retVals = NULL ;
try {
retVals = new bases1 ;
} catch(bads_allocs &faileds) {
cerrs<<faileds.what() ;
exit(-1) ;
}
}
Please help me.
Thank you.
Bookmarks