You cannot copy content of this page.

Daily Archive December 23, 2012

Function Prototype & Function Overloading

Function Prototype:

Function prototype also referred to as function signature specifies the number of arguments and return type of the function to the compiler. Function prototype is required when a function is invoked/called before it is defined. The following statement defines function prototype.

            <Return type> function_name(arguments);

where return type is any valid C++ data type. The arguments are the parameters or values passed to the function when it is invoked. The argument variable names in prototype are optional.

Function Overloading:

Function overloading refers to defining different functions with the same name but with different arguments and return types. This is also referred to as functional polymorphism, as overloading is a form of polymorphism. This function to be invoked is determined by the type and number of arguments passed to that function.

For example: if we have to find the sum of two numbers of type int as well as float type we need not define two different functions with different names.  Now we can define both the functions bearing same name but different argument type.

int add (int a, int b);

float add(float a, float b);

Now the same function ‘add’ sums up two integer values and returns an integer as well as float values, thereby returning float value.

Tags,

Object Oriented Programming


Object Oriented Programming:

Object-Oriented Programming is a program design approach. It is incorporated with several features and new concepts, which are quite different from other programming techniques such as Modular programming, Structural programming or Procedural programming. It supports objects that are data abstraction with an interface of named operations and a hidden local state. It ties data along with their methods that operate on data. It supports data encapsulation feature by encapsulating the data, which cannot be accessed by external functions. Object orientation demands the concept of data encapsulation so that an object does not permit other objects to access its data and operates directly. The services of an object can be called upon through messages, classes are defined that contains the data members along with methods or functions that operate on data. Data Abstraction, which represents only essential features to the outside world, again is a striking feature of OOPs, besides this inheritance supports reusability and extensibility of code segments, polymorphism implemented through function overloading and operation overloading, compile time polymorphism or dynamic binding are some of the other features of OOPs.

It is different from conventional programming approaches, such as Modular programming, Procedural programming, Top-down & Bottom-up programming, Structural programming, as it incorporates powerful features as mentioned to provide extra power to the programming approach. OOPs model the real world objects with great ease, which was quite difficult with conventional programming languages. There was no data security feature and it moved freely around the system. Overloading, Inheritance, Dynamic binding of modules etc. empowered it further and thus proved to be a good programming approach over other programming approaches.

Tags

x Close

Like Us On Facebook