shilpigupta.itgo.com\ FAQ-C

Home

Email

Guest Book

About me

Hit counter

Last updated: Oct. 7,2002

Q.1    What is OO technology?

Objects, classes and inheritance.

OOP/language is one that supports these tools.

Real goals of OO : abstraction, encapsulation, data hiding, comprehensibility and reusability.

It has a former paradigm : structured analysis, design and programming.

An object is a region of storage with associated semantics, it has a state and provide services. An object is an instance of a class.

A class has a name, and describes the state (member data) and services (member functions) provided by its objects.

Inheritance relate classes and facilitates polymorphism and dynamic binding.


Q.2    Who makes C++ standardize?

ANSI (American National Standard Institute) and ISO (International Standard Organization) groups work together, and make C++ a standardize in programming world in 1996.

ANSI-C++ committee is called X3J16.

ISO-C++ committee is called WG21.


Q.3    Does a class in C++ is designed to export attributes?

No, the actual purpose of class is to provide services.

A class is a medium to abstract behavior, not just to encapsulate data and functions. If a detached user expects services to access an attribute, those services should exist.


Q.4    How can a class be converted to a struct?

For this,

A struct's default access is public while on the other hand the class's default access is private. For base class we may explicitly define public, private or protected.


Q.5    Why should we give preference to new instead of malloc( ) ?

Due to the following reasons:

  1. Creation  :  new creates an object, where as malloc ( )  allocates memory only.

  2. Safety     :  new returns a pointer of appropriate type, where as malloc ( ) returns void pointer to be defined              explicitly.

  3. Flexibility :  new can be overloaded on a class-by-class basis, where as malloc( ) cannot be.


Q.6    Consequences of deleting a pointer twice?

Suppose we have a pointer p. The first time delete the pointer p, the object *p is safely destructed, and the memory pointed to by p is safely returned to the heap. The second time when we pass the same pointer to delete without a subsequent new that returned that pointer, the remains of what used to be an object at *p is passes to the destructor (which could be disastrous), and the memory pointed to by p is handed back to the heap a second time. This will likely corrupt the heap and its list of free memory.


Q.7    What does insline do?

Declaration   :   void insline(void);
Prototype in  : <conio.h>
Remarks:
insline inserts an empty line in the text window at the cursor position using the current text background color.
All lines below the empty one move down one line, and the bottom line scrolls off the bottom of the window.


<  TOP >