tags:

views:

141

answers:

1

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
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
BTW, if defined just in a .h file, are the functions all inline ones?
Benny
@Benny, yes but only as far as that is meaningful - the compiler is always free to decide to not inline a function.
Andy Dent
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
thanks guys. it is clear now.
Benny