E
Espen Ruud Schultz
Have a look at this code:
#include <iostream>
class TypeTXT {
public:
TypeTXT( void ) { std::cout << " TypeTXT" << std::endl; }
~TypeTXT( void ) { std::cout << "~TypeTXT" << std::endl; }
void Function( void ) { std::cout << "TypeTXT::Function" <<
std::endl; }
};
class TypeBMP {
public:
TypeBMP( void ) { std::cout << " TypeBMP" << std::endl; }
~TypeBMP( void ) { std::cout << "~TypeBMP" << std::endl; }
void Function( void ) { std::cout << "TypeBMP::Function" <<
std::endl; }
};
template< class Object > class DataObject {
public:
DataObject( void ) { std::cout << " DataObject" << std::endl; }
~DataObject( void ) { std::cout << "~DataObject" << std::endl; }
void Function( void ) { std::cout << "DataObject::Function" <<
std::endl; }
};
int main( void ) {
DataObject< TypeTXT > ObjectTXT;
DataObject< TypeBMP > ObjectBMP;
ObjectTXT.Function();
ObjectBMP.Function();
return 0;
}
I guess you can see what I'm trying to do. First I want to execute the
c'tor and d'tor of the two classes TypeTXT and TypeBMP. I also want to
execute functions belonging to these classes through the template class.
How do I do all this?
TIA!
, Espen
#include <iostream>
class TypeTXT {
public:
TypeTXT( void ) { std::cout << " TypeTXT" << std::endl; }
~TypeTXT( void ) { std::cout << "~TypeTXT" << std::endl; }
void Function( void ) { std::cout << "TypeTXT::Function" <<
std::endl; }
};
class TypeBMP {
public:
TypeBMP( void ) { std::cout << " TypeBMP" << std::endl; }
~TypeBMP( void ) { std::cout << "~TypeBMP" << std::endl; }
void Function( void ) { std::cout << "TypeBMP::Function" <<
std::endl; }
};
template< class Object > class DataObject {
public:
DataObject( void ) { std::cout << " DataObject" << std::endl; }
~DataObject( void ) { std::cout << "~DataObject" << std::endl; }
void Function( void ) { std::cout << "DataObject::Function" <<
std::endl; }
};
int main( void ) {
DataObject< TypeTXT > ObjectTXT;
DataObject< TypeBMP > ObjectBMP;
ObjectTXT.Function();
ObjectBMP.Function();
return 0;
}
I guess you can see what I'm trying to do. First I want to execute the
c'tor and d'tor of the two classes TypeTXT and TypeBMP. I also want to
execute functions belonging to these classes through the template class.
How do I do all this?
TIA!
, Espen