Can it be defined in .h and .cpp file or it has to be defined in a single .h file?
+1
A:
You can define in just a .h or split the class definitions just as you would for traditional C++.
Note that for properties you will need to nest your get and set methods with proper scoping, eg:
void MyModel::AProperty::set(bool b)
{
mBackingVariableForAProperty = b;
}
Andy Dent
2009-11-24 03:57:07
It should be noted that all the usual limitations apply; in particular, it is not possible to define two classes which use methods of each other in just two header files.
Pavel Minaev
2009-11-24 04:00:39
BTW, if defined just in a .h file, are the functions all inline ones?
Benny
2009-11-24 04:18:55
@Benny, yes but only as far as that is meaningful - the compiler is always free to decide to not inline a function.
Andy Dent
2009-11-24 04:21:22
All functions that are defined _within the body of the class_ are implicitly `inline` (it doesn't matter if it's an .h or a .cpp file). However, a function with `inline` specifier is not necessarily inlined by the compiler - it's just a hint, and most modern compilers ignore it and decide on their own.
Pavel Minaev
2009-11-24 04:25:46
thanks guys. it is clear now.
Benny
2009-11-24 04:41:25