Lecture notes on



Download 232,82 Kb.
bet15/45
Sana07.07.2022
Hajmi232,82 Kb.
#755880
1   ...   11   12   13   14   15   16   17   18   ...   45
Bog'liq
285 OOPS lecture notes Complete-конвертирован

cout<<”\n final value=”<
//function definitions
float value (float p,int n, float r)
{

float si; si=(p*n*r)/100; return(si);
}
void printline (char ch,int len)
{
for(inti=l;i<=len;i++) cout<
}
output:-
* * * * * * * * * * * * * * * * final value=10056.71613
= = = = = = = = = = = = = = =
Advantage of providing the default arguments are:

  1. We can use default arguments to add new parameters to the existing functions.

  2. Default argument s can be used to combine similar functions into one.



CONST ARGUMENT:-


In C++, an argument to a function can be declared as unit as const as shown below.
int strlen(const char *p); int length(const string &s);
The qualifier const tells the compiler that the function should not modify the argument .the compiler will generate an error when this condition is violated .This type of declaration is significant only when we pass arguments by reference or pointers.

LECTURE-12


FUNCTION OVERLOADING:

Overloading refers to the use of the same thing for different purposes . C++ also permits overloading functions .This means that we can use the same function name to creates functions that perform a variety of different tasks. This is known as function polymorphism in oops.


Using the concepts of function overloading , a family of functions with one function name but with different argument lists in the functions call .The correct function to be invoked is determined by checking the number and type of the arguments but not on the function type.
For example an overloaded add() function handles different types of data as shown

below.



Download 232,82 Kb.

Do'stlaringiz bilan baham:
1   ...   11   12   13   14   15   16   17   18   ...   45




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish