Skip to main content

12th HSC free notes of c++ language part 2. Theory

 Explain the concept of function overloading with example .

The use of same function name to create function that perform a variety of different tasks is called as function overloading .
Overloading refers to the use of same thing for different purpose .
Function overloading or function polymorphism , is an example of compile time polymorphism .
Using the concept function overloading , create a family of function with one function name but with different argument lists.
The function would perform different operation , depending on argument list in function call.
The correct function to be invoked is determined by checking the number and the type of the argument and not on the function type .
When a function is called , the compiler first matches the prototype having same number and types of arguments and then calls appropriate function for execution . A best match must be unique.

Pointers :
• A pointer is a variable which hold the memory address of another variable
• * operator is use to declear pointer in c++.
• It takes the form as :
• Datatype *variable name ;
• E.g. int *ptr:
• The above declearation will create a variable ptr which is a pointer variable and which will point to a variable whose datatype is integer.
• The data type of ptr is not integer but datatype of variable which ptr will point is integer .

Advantages of pointer :
• It allows to pass variable array ,function, string, structure, object as function arguments .
• It allow to return structured variable from functions.
• It support dynamic allocation and deallocation of memory segment .
• By using pointer variable can be swapped without physically moving them
• It allow to establish link between data elements or objects.

Call by value :
• Pointer is a variable which hold the address of another variable.
• * operator are used to declear pointer .
• The use of pointer in a function definition may be classified into two group :
Call by value.
Call by reference .
• Call by value :
• When the portion of the program invokes a function control will be transfer from main function to the calling function and the value of actual argument is copied to the function .
• Within function the actual value may be altered or changed.
• When the control is transferred back from function to the program, altered values are not transeferred back this type of passing formal arguments to the

Call by reference :
• Call by reference :
• In call by reference when the function is called by a program the address of actual argument are copied on to the formal arguments i.e.formal and actual argument referring same memory location .
• Therefore change in value of formal argument affect the value of actual arguments
• The content of variable that are alter within thee function are return to calling portion of program in alter form.

Comments

Post a Comment

Popular posts from this blog

partitioning (operatimg system ).

 WHAT IS PARTITIONING ? Certain operating system use partitioned memory management to allow multiprogramming . • Partitioning means dividing main memory into various sections.  • These section are called as partitions.  • There are two types of partitions: 1) fixed partition .    2) variable partition.   Fixed partition  .  • In this method partitions are fixed at the time of system generation . At this time , system manager has to declear partition time.  • Fixed partition are also called static partition . On declearing fixed partition , the operating system create partition description table.  • It reduces the uses the CPU utiliisation .  • It reduces the degree of multiprogramming. .    variable partition .     In variable partition number of partition and their size are variable  • They are not defined at the time of system generation .  • These partition are created by operating systems...

Free notes of the operating system some imp questions

 1. ALU  2. STACK POINTER 3. PROGRAM COUNTER 4. INSTRUCTION REGISTER AND DECODER ALU ( ARITHMATIC AND LOGIC UNIT ) It is 8 bit unit  In this arithmetic and logical operation are carried out . ALU contain the binary adder to perform addition substracion by 2’s complement method Data is supplied by memory devices and input ouput devices The result is typically stored in the accumulator. STACK POINTER:- Stack poiointer is a 16 bit register which contain the address of top of stack With the help of incrementer and decrementer stack pointer perform their work The stack pointer is incremented when data is push  The stack pointer is decrementd when data is pop. INSTRUCTION REGISTER AND DECODER :- During the instruction fetch, the first 8 bit of instruction is transfer to the 8 bit instruction register The content of instruction register are available to the instruction decoder The output of decoder get by timing signals, ALU & data buffer. PROGRAM COUNTER:- Program coun...

Important MCQ and imp programs of html and c++.

  Some important MCQ . Ans. :- a)-i) , b)- i) , c)- iii) , d)- iii)                        Ans. :- a)- ii) , b)- iii) , c) - iii) , d)- ii)                         Ans.:- a)- ii) , b) - i), c) - iii) , d) - ii)                        And. :- a)- iii) , b)- ii) , c)- iii) , d) - iii)                       Ans. :- a) - ii) , b) - i), c)- iii) , d) - iii)                      Some important previous year questions of programming. 1) 2) 3) 4)