Neo: tiens voila un hello world ( c)(tm)(r) kufa.badcode
( note il faut le rtti d active sous vc)
- ifndef _TEST_HPP_
- define _TEST_HPP_
- include < stdio.h>
- include < string.h>
- include < typeinfo>
namespace HelloWorld { enum { hello = 6, world = 6 }; }
namespace hello { static const char *world = " %s%c%s\n"; }
namespace world_{ static const char hello_ = ´%´; }
struct This
{
const char *operator+( const char *h ) { return strstr( typeid(*this).name(), h ) ; }
virtual int hello() = 0;
};
class Hello : private This
{
public:
template<class T>
void operator() ( const T& t ) ;
virtual int hello() { return HelloWorld::hello; }
private:
enum { space = ´ ´ };
};
struct world : public This { virtual int hello() { return HelloWorld::world; } };
namespace
{
static const char *helloworld = " %c%c%ds";
struct World : public world { enum { world_ = ´.´ } ;
};
}
- endif / * _TEST_HPP_ */
- include " Test.hpp"
template<> void Hello::operator() ( const World& t )
{
char hello[HelloWorld::hello];
char world[HelloWorld::world];
char hello_[HelloWorld::hello];
char world_[HelloWorld::world];
sprintf( hello, ::helloworld, world_::hello_, t.world_, HelloWorld::hello ) ;
sprintf( world, ::helloworld, world_::hello_, t.world_, HelloWorld::world ) ;
sprintf( hello_, hello, *this + " H" ) ;
sprintf( world_, world, struct world() + " w" ) ;
printf( hello::world, hello_, space, world_ ) ;
}
int main( int argc, char ** argv )
{
Hello()(World());
return 0;
}