class BaseClass {
public:
BaseClass(const byte *buff, long size) {
// Some Computation
}
};
class DerivedClass: public BaseClass {
public:
std::vector<byte> filebuff;
long buff_size;
DerivedClass(): BaseClass(/*How should I send stuff here?*/)
{
}
/*return type??*/ cal_func(){
// Some computation involving file descriptors.
// Store result in filebuff. Store size of filebuff in buff_size.
return /*what??*/;
}
}
I can only think of the following solution:
DerivedClass(): BaseClass(&filebuff[0], cal_func)
In the above case, I will make function func() to return length of filebuff. I am relying on the fact that filebuff is only an address and hence it doesn't matter whether the compiler puts the computed value of func on the stack first or the first arg, filebuff.
Please tell me whether this is a correct method for doing so. If the first argument wasn't an address and some other computed value which would've required the computation carried out in the function func, what would be the best way to go about it?