Yes you can. The myvar
member will have the value of val
before the increment.
We should considere that val will have a type supporting the post-increment operator.
template <class T> struct MyClass
{
MyClass(T val): myvar(val++) {/*body*/}
// ^
protected:
T myvar;
};
MyClass<int> foo( 1 );
// Here myvar will have the value 1
And don't forget the type of val
passed to the MyClass
constructor.