tags:

views:

35

answers:

1

Hello.

Qt library includes advanced meta-programming capabilities using they own preprocessing moc compiler. Does anyone knows, is it possible to create some kind of mix-ins via it? For example, i have a QString and want to add a method to it without sub-classing and changing existing code. Does Qt have such solutions for that?

+2  A: 

I'm pretty sure that what the moc compiler isn't considered meta-programming according to the most common definition.

Furthermore, you can't add methods to a class using it.

Infact, in C++, you can never add methods to a class outside its declaration and moc (or any other QT utility) never actually touches the definition of the class. it only adds some meta-information to it and additional code which takes care of the signals and slots mechanism. This has very little to do with actual meta-programming.

shoosh