Quote Originally Posted by GunkutA View Post
But after I add these lines, when I run, "The program has unexpectedly finished." error appears.
This is usually the result of using a pointer that is not initialised (a run time C++ issue and not a compilation issue). There's not enough of your code here to make the problem obvious.

If removing both lines removes the problem then a guess would be that the constructor of the USB object is failing.
If removing only the connect() call removes the problem then my guess is the USBInstance variable here is uninitialised ( probably not the same USBInstance as you created), or the slot is called and does something with an invalid pointer.

Run your program your in debugger and let it crash. You should be able to see a backtrace leading from the point of failure back into your code. Inspect that back trace and inspect variable involved for clues.