Search for notes by fellow students, in your own course and all over the country.
Browse our notes for titles which look like what you need, you can preview any of the notes via a sample of the contents. After you're happy these are the notes you're after simply pop them into your shopping cart.
Title: CLASS XII C++ COMPUTER
Description: ALL OOP CONCEPTS FROM CBSE COMPUTER SCIENCE CLASS 12. THIS WILL HELP YOU TO ACE THROUGH ALL OBJECT ORIENTED CONCEPTS.
Description: ALL OOP CONCEPTS FROM CBSE COMPUTER SCIENCE CLASS 12. THIS WILL HELP YOU TO ACE THROUGH ALL OBJECT ORIENTED CONCEPTS.
Document Preview
Extracts from the notes are below, to see the PDF you'll receive please use the links above
OOP’S CONCEPTS
(Name and explain any -)
1
...
3
...
5
...
Polymorphism is implemented in C++ through FUNCTION OVERLOADING
...
To overload a function use same function name but with different number of argument list to avoid AMBIGUITY
...
Square 2
...
Triangle
#include
h>
Void area (float s);
Void area (float l, float b);
Void area (float a, float b, float c);
Void main ()
{
Float s,a,b,c,l;
Cout<<”Enter l,b”;
Cin>>l>>b;
area(l,b);
cout<<”Enter a,b,c”;
cin>>a>>b>>c;
area(a,b,c);
cout<<”Enter s”;
cin>>s;
area(s);
}
Void area (float s)
{
Float A=s*s;
Cout<<”Area=”<}
Void area (float a, float b, float c)
{
Float S, A;
S=(a+b+c)/2
...
#include
h>
Float volume (float a)
{
return(pow(a,3)); //return(a*a*a)
}
Float volume(float r,float h)
{
Return (3
...
THE RULES OF FUNCTION OVERLOADING
1
...
2
...
”
NOTE:
a)float Area (float s);
//This one is correct
b)double Area (float x); //Error
It should be –
double Area (double x);
NOTE:
Suppose it calls:-
a) float Area(float s);
b) double Area(double x);
Area (2
...
5);//b
Class XI :
1)
25 - int
25L -long int
2
...
5f -float
2) ‘0’ “0” 0
‘0’ -char const
“0”-string const
0 -integer const
3) 45, 045, 0x453, 45
...
63-float const
DEFAULT ARGUMENTS: What is the benefit of using default arguments in a function
...
Values can be initialized in the argument list during declaration(prototyping) of a function, which is useful in case a
matching argument is not passed in the function call statement
...
✓ For Eg: void sum (int a=10, int b=20, int c=25);
void main ()
{
sum(); //10+20+25
sum(25,100);//25+100+25
sum(100,200,300);//100+200+300
}
void sum (int a,int b,int c)
{
int s=a+b+c;
cout<
OR- can avoid the prototype
...
void sum(int a=10, int b, int c); //Error
//b&c should be assigned
...
void sum (int a, int b=20, int c=30); //Error
corrected- void sum (int a, int b-20, int c=30);
3
...
Default arguments might not work for all possible combination of arguments, whereas function maybe
overloaded for all possible combination of arguments
...
With function overloading, multiple function definitions can be executed, but with default arguments exactly
one function definition is executed
...
void print () //Function 1
{
for (int k=1; k<=80; k++) cout>>”-“;
cout<
void print (int N) //Function 2
{
for (int k=1; k<=N; k++) cout>>”*”;
cout<
void print (char c, int N)//Function 3
{
for( int k=1; l<=N; k++) cout>>”C”;
cout<
void print (int M, int N) //function 4
{
for (int k=1; k<=N; k++) cout<
void main()
{
int A=9, B=4, C=3;
char K=’#’;
print (K,B);
print (A,C);
}
O/P :-
Polymorphism OR Function Overloading
...
A Class is a way to bind the data describing an entity and associated member functions together under a
single unit
...
Data Member- They are data type properties that describe the characteristics of a class
...
Member Functions- They are a set of operations that maybe applied to the object of that class
...
3
...
They are classified as
private, protected and public members
...
4
...
class Student //tagname is Student
{
private:
int rollno;
char name[20];
protected:
float maeks;
public:
char grade;
Scope of the member if the object is class scope
...
input();
cout<
• Memory space is allocated to data members only when the objects are declared
...
• Each object create separate memory space for its data members to hold different values
...
✓ Eg
...
enter();
E2
...
show();
E2
...
SIGNIFICANCE OF ACCESS SPECIFIER:
Access Specifier is a way to specify the scope and accessibility of members of a class
...
Private visibility mode
2
...
Public visibility mode
PRIVATE AND PROTECTES VISIBILITY MODE WITHIN THE CLASS:❖ DIFFERENCE1
...
2
...
❖ SIMILARITY
Both are not available to the non-member function hence data hiding is implemented through private and
protected members
...
class Stock
{
int itemno;
char itemname[20];
protected:
void enter()
{
cin>>itemno;
gets(itemname);
}
public:
void show()
{
enter();
cout<
};
void main()
{
stock s;
s
...
Difference• By default all members are private whereas public members have to be specified as public
...
• Private members can only be accessed within the member functions of the same classes whereas
public members are available to the non-member functions by prefixing the object of that class
...
In both the cases, members can be called from the member functions of the same class
...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Title: CLASS XII C++ COMPUTER
Description: ALL OOP CONCEPTS FROM CBSE COMPUTER SCIENCE CLASS 12. THIS WILL HELP YOU TO ACE THROUGH ALL OBJECT ORIENTED CONCEPTS.
Description: ALL OOP CONCEPTS FROM CBSE COMPUTER SCIENCE CLASS 12. THIS WILL HELP YOU TO ACE THROUGH ALL OBJECT ORIENTED CONCEPTS.