I do not understand the following problem.
class InnerBox { public: InnerBox() : mContents(123) { }; private: int mContents; }; class Box { public: Box(const InnerBox& innerBox) : mInnerBox(innerBox) { }; private: InnerBox mInnerBox; }; void SomeFunction(const Box& box) { return; } int main() { Box box(InnerBox());
Full error message (Visual Studio 2010)
error C2664: 'SomeFunction' : cannot convert parameter 1 from 'Box (__cdecl *)(InnerBox (__cdecl *)(void))' to 'const Box &'
The fix is simple:
int main() { InnerBox innerBox; Box box(innerBox); SomeFunction(box); return 0; }
Is this an MSVC issue, and if someone couldn’t explain that I'm sorry for the language, I forbid me to call Box box(InnerBox());
?
source share