class member is another class' object

前端 未结 2 438
别跟我提以往
别跟我提以往 2021-01-26 01:45

I am a new C++ user...

I have a question regarding how to declare a member of a class \"classA\" that is an object of another class \"classB\", knowing that \"classB\" h

2条回答
  •  别那么骄傲
    2021-01-26 02:26

    What you need is initializer list:

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

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

提交回复
热议问题