1. Define the syntax and semantics for a function template?

Templates is one of the features of C++. Using templates, C++ provides a support for generic programming.

We can define a template for a function that can help us create multiple versions for different data types.

A function template is similar to a class template and it syntax is as follows:
template <class T>
Return-type functionName (arguments of type T)
{
//Body of function with type T wherever appropriate
}

2. Explain Component Object Model?

COM defines an API to allow for the creation of components for use in integrating custom applications or to allow diverse components to interact.
But in order to interact, components must adhere to a binary structure specified by Microsoft.

As long as components adhere to this binary structure, components written in different languages can interoperate.

3. How COM provide the language transparency?

COM defines an API to allow for the creation of components for use in integrating custom applications or to allow diverse components to interact.

But in order to interact, components must adhere to a binary structure specified by Microsoft.
As long as components adhere to this binary structure, components written in different languages can interoperate.

4. Explain IUnknown interface?

IUnknown interface provides clients like DirectX control of to get pointers to other interfaces. All COM interfaces are inherited from IUnknown interface. It is used In multiple inheritance where the various interfaces can share one implementation of IUnknown.

5. Why COM need GUIDs?

A globally unique identifier (GUID) is used for unique IDs. No two GUIDs are the same no matter what computer they were generated on. The attribute clsid defines the GUID of the associated ActiveX control to use.

6. Explain GUID?

GUID stands for Globally Unique Identifier.
A 16-byte number generated by Microsoft programs that uniquely identifies a network or user or computer or document. It is one of the elements of information that can be passed when you connect to an Internet site, and it may be stored in cookies.

7. Explain type library?

A file or component within another file that contains standard descriptions of exposed objects, properties, and methods

A type library contains a binary description of an interface exposed by a COM-component. In this sense, they contain the same information that is contained in an IDL (Interface Definition Language) file.

8. Explain ActiveX and OLE?

Object Linking and Embedding (OLE) is about using documents generated by one application inside another application.

ActiveX is a Microsoft rebranding of OLE with more focus on smart Windows controls.

9. Explain dual interfaces?

A dual interface allows its methods to be accessed as dispinterface methods or as vtable methods.

Dual interface is one that supports both - IDispatch interface and vtbl-based interface. Therefore, it might be used in scripting environment like VBScript and yet to use power and speed of vtbl-based interface for non-scripting environment.

10. Explain shallow and deep copy?

A shallow copy just copies the values of the data as they are. Even if there is a pointer that points to dynamically allocated memory, the pointer in the copy will point to the same dynamically allocated.

Download Interview PDF