class member is another class' object

僤鯓⒐⒋嵵緔 提交于 2019-12-02 09:10:10

What you need is initializer list:

myClass::myClass (string videoFileName) : myCapture(videoFileName) {
}

This will construct myCapture using its constructor that takes a string argument.

If you want a VideoCapture to be a member of the class, you don't want this in your class definition:

VideoCapture myCapture (string videoFileName /* :  I am not sur what to put here */ )  ;

Instead you want this:

VideoCapture myCapture;

Then, your constructor can do this:

myClass::myClass (string PLEASE_GIVE_ME_A_BETTER_NAME)
: myCapture(PLEASE_GIVE_ME_A_BETTER_NAME),
videoFileName(PLEASE_GIVE_ME_A_BETTER_NAME)
{
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!