That's a bit difficult to explain just here. You'll have to create a COM dll. I always use ATL for this. The ATL COM appwizard builds a framework for you (the COM dll, which houses the COM objects you're going to expose) and then you have to insert ATL COM objects yourself. I recommend you first do some reading about this though, because it's a quite different approach than "conventional" C++ programming.
Greetings,
Rick