Wednesday, December 31, 2008

C / C++ - Frequently Asked Questions

1.) How To Split an Image File In C Launguage?

To split an image file various logics are there.the best logic in such a way that take the size of the file using c file functions and split into the pieces how many required by asking the input.

2.)What is the difference between an ARRAY and a LIST?

Array is collection of homogeneous elements. List is collection of heterogeneous elements. For Array memory allocated is static and continuous. For List memory allocated is dynamic and Random. Array: User need not have to keep in track of next memory allocation. List: User has to keep in Track of next location where memory is allocated.

3.)Define a constructor - what it is and how it might be called?


constructor is a member function of the class, with the name of the function being the same as the class name. It also specifies how the object should be initialized

4.)Define a constructor - what it is and how it might be called?


constructor is a member function of the class, with the name of the function being the same as the class name. It also specifies how the object should be initialized Ways of calling constructor:
1) Implicitly: automatically by complier when an object is created.
2) Calling the constructors explicitly is possible, but it makes the code unverifiable.

5.)You have two pairs: new() and delete() and another pair : alloc() and free(). Explain differences between eg. new() and malloc()?

1.) “new and delete” are preprocessors while “malloc() and free()” are functions. [we dont use brackets will calling new or delete].
2.) no need of allocate the memory while using “new” but in “malloc()” we have to use “sizeof()”.
3.) “new” will initlize the new memory to 0 but “malloc()” gives random value in the new alloted memory location [better to use calloc()].

6.)Explain term POLIMORPHISM?

POLYMORPHISM : A phenomenon which enables an object to react differently to the same function call. in C++ it is attained by using a keyword virtual

7.)What are 2 ways of exporting a function from a DLL?

1.Taking a reference to the function from the DLL instance.
2. Using the DLL ’s Type Library

8.)Describe PRIVATE, PROTECTED and PUBLIC – the differences?

The Difference Between The private Public And Protected member are: public methods/attributes are accessible to all classes. protected are accessible to class and derived classes. private are only for class (not for derived classes)

No comments: