Presentation on class and object in Object Oriented programming.Enam Khan
This Presentation May help you understand about class and object in c++ Programming Language.
I tried to made it very easy, and my instructor liked it very much.
So, i decide to share it.
Presentation on class and object in Object Oriented programming.Enam Khan
This Presentation May help you understand about class and object in c++ Programming Language.
I tried to made it very easy, and my instructor liked it very much.
So, i decide to share it.
Classes extend the built-in capabilities of C++ able you in representing and solving complex, real-world problems. A class is an organization of data and functions which operate on them. Data structures are called data members and the functions are called member functions, the combination of data members and member functions constitute a data
object or simply an object.
Class is a group of data member and member functions. Another word class is a collection of objects of similar type.
To create a class, use the class keyword followed by a name for the object. Like any other declared variable, the class declaration ends with a semi-colon. The name of a class follows the rules we have applied for variable and function names.
Classes extend the built-in capabilities of C++ able you in representing and solving complex, real-world problems. A class is an organization of data and functions which operate on them. Data structures are called data members and the functions are called member functions, the combination of data members and member functions constitute a data
object or simply an object.
Class is a group of data member and member functions. Another word class is a collection of objects of similar type.
To create a class, use the class keyword followed by a name for the object. Like any other declared variable, the class declaration ends with a semi-colon. The name of a class follows the rules we have applied for variable and function names.
This is the object oriented lecture nmbr 3rd , if you want lecture 2 or 1 u can check it my account , this is the programing tutorial, please follow me and thank you
Classes and Objects
Classes in C++
Declaring Objects
Access Specifiers and their Scope
Defining Member Function
Overloading Member Function
Nested class
Constructors and Destructors
Introduction
Characteristics of Constructor and Destructor
Application with Constructor
Constructor with Arguments (parameterized Constructors)
Destructors
Synthetic Fiber Construction in lab .pptxPavel ( NSTU)
Synthetic fiber production is a fascinating and complex field that blends chemistry, engineering, and environmental science. By understanding these aspects, students can gain a comprehensive view of synthetic fiber production, its impact on society and the environment, and the potential for future innovations. Synthetic fibers play a crucial role in modern society, impacting various aspects of daily life, industry, and the environment. ynthetic fibers are integral to modern life, offering a range of benefits from cost-effectiveness and versatility to innovative applications and performance characteristics. While they pose environmental challenges, ongoing research and development aim to create more sustainable and eco-friendly alternatives. Understanding the importance of synthetic fibers helps in appreciating their role in the economy, industry, and daily life, while also emphasizing the need for sustainable practices and innovation.
Model Attribute Check Company Auto PropertyCeline George
In Odoo, the multi-company feature allows you to manage multiple companies within a single Odoo database instance. Each company can have its own configurations while still sharing common resources such as products, customers, and suppliers.
How to Make a Field invisible in Odoo 17Celine George
It is possible to hide or invisible some fields in odoo. Commonly using “invisible” attribute in the field definition to invisible the fields. This slide will show how to make a field invisible in odoo 17.
Unit 8 - Information and Communication Technology (Paper I).pdfThiyagu K
This slides describes the basic concepts of ICT, basics of Email, Emerging Technology and Digital Initiatives in Education. This presentations aligns with the UGC Paper I syllabus.
2024.06.01 Introducing a competency framework for languag learning materials ...Sandy Millin
http://sandymillin.wordpress.com/iateflwebinar2024
Published classroom materials form the basis of syllabuses, drive teacher professional development, and have a potentially huge influence on learners, teachers and education systems. All teachers also create their own materials, whether a few sentences on a blackboard, a highly-structured fully-realised online course, or anything in between. Despite this, the knowledge and skills needed to create effective language learning materials are rarely part of teacher training, and are mostly learnt by trial and error.
Knowledge and skills frameworks, generally called competency frameworks, for ELT teachers, trainers and managers have existed for a few years now. However, until I created one for my MA dissertation, there wasn’t one drawing together what we need to know and do to be able to effectively produce language learning materials.
This webinar will introduce you to my framework, highlighting the key competencies I identified from my research. It will also show how anybody involved in language teaching (any language, not just English!), teacher training, managing schools or developing language learning materials can benefit from using the framework.
Ethnobotany and Ethnopharmacology:
Ethnobotany in herbal drug evaluation,
Impact of Ethnobotany in traditional medicine,
New development in herbals,
Bio-prospecting tools for drug discovery,
Role of Ethnopharmacology in drug evaluation,
Reverse Pharmacology.
Read| The latest issue of The Challenger is here! We are thrilled to announce that our school paper has qualified for the NATIONAL SCHOOLS PRESS CONFERENCE (NSPC) 2024. Thank you for your unwavering support and trust. Dive into the stories that made us stand out!
Instructions for Submissions thorugh G- Classroom.pptxJheel Barad
This presentation provides a briefing on how to upload submissions and documents in Google Classroom. It was prepared as part of an orientation for new Sainik School in-service teacher trainees. As a training officer, my goal is to ensure that you are comfortable and proficient with this essential tool for managing assignments and fostering student engagement.
Instructions for Submissions thorugh G- Classroom.pptx
Object and class presentation
1.
2. C STRUCTURES
REVISITED
• One of the unique facilities provided by C language is
structure
• It is used to group logically related data items
• It is user defined data-type and once structure type is
defined, variables of that type can be created
2
3. LIMITATIONS OF C
STRUCTURE
• They don’t allow data hiding
• Structure members can be accessed using structure
variable by any function any where in the scope
• C does not allow the structure data type to be treated like
built-in data type
3
4. AN INTRODUCTION TO CLASSES
• A class is a building block of OOP. It is the way to bind the data
and its logically related functions together.
• An abstract data type that can be treated like any other built in
data type.
6. SPECIFYING A CLASS
Specification of a class consists of two parts:
• Class declaration
• Function definition
Syntax:
class class_name
{
private:
variable declarations
function declarations
public:
variable declarations
function declarations
};
6
7. CONTD…
The key feature of OOP is data hiding.
Generally, data within a class is made private and the
functions are public.
So, the data will be safe from accidental manipulations, while
the functions can be accessed from outside the class
However, it is not necessary that the data must be private
and functions public
7
8. CREATING OBJECTS
Once a class has been declared, variables of that type can be
created by using the class name as data-type
Test t1; //memory for t1 is allocated
This statement creates a variable t1 of type test.
The class variables are known as objects
t1 is called object of class test.
More than one object of a class can be created
8
9. CONTD…
Objects are also called instances of class
Objects can be created as follows:
class employee
{
int id;
char name[20];
public:
void getname();
void putname();
}e1, e2, e3;
9
10. MEMBER FUNCTION
Member function’s name is visible outside the class.
It can be defined inside or outside the class.
It can have access to private, public and protected data
members of its class, but cannot access private data
members of another class.
11. ACCESSING CLASS
MEMBERS
The class members are accessed using dot operator
However it works only for the public members
The dot operator is called member access operator
The general format is:
class-object.class-member;
Eg: e1.getdata();
The private data and functions of a class can be accessed only
through the member functions of that class
11
12. DEFINING MEMBER
FUNCTIONS
Member function can be defined in two ways
Outside the class
Inside the class
The code for the function body would be identical in both the
cases i.e perform same task irrespective of the place of
definition
12
13. OUTSIDE THE CLASS
In this approach, the member functions are only declared
inside the class, whereas its definition is written outside the
class
General form:
Return-type class-name::function-name(argument-list)
{
--------------
-------------- // function body
--------------
}
13
14. CONTD…
Eg:
class A
{
int x, y;
public:
void getdata (); // function declaration inside the
class
}
void A :: getdata()
{
cin>>x>>y; // function body
}
14
15. INSIDE THE CLASS
Function body can be included in the class itself by replacing
function declaration by function definition
If it is done, the function is treated as an inline function
Hence, all the restrictions that apply to inline function, will
also apply here
15
16. Eg:
class A
{
int a, b;
public:
void getdata()
{
cin>>a>>b;
}
};
Here, getdata() is defined inside the class.
So, it will act like an inline function
A function defined outside the class can
also be made ‘inline’ by using the qualifier
‘inline’ in the header line of a function
definition
16
17. NESTED MEMBER
FUNCTIONS
An object of the class using dot operator, generally, calls a
member function of a class
However, a member function can be called by using its name
inside another member function of the same class.
This is known as “Nesting Of Member Functions”
17
18. PRIVATE MEMBER
FUNCTIONS
Member functions are in general made public
But in some cases, we may need to make a function a private
to hide them from outside world
Private member functions can only be called by another
function that is a member of its class
Objects of the class cannot invoke it using dot operator
18
19. Eg:
class A
{
int a, b;
void read(); //private member function
public:
void update();
void write();
};
void A :: update()
{
read(); // called from update() function.
no object used
}
If a1 is an object of A, then the following statement is
not valid
a1.read();
This is because, read is a private member function
which cannot be called using object and dot operator
19
20. STATIC MEMBER
FUNCTION
In a class, functions can also be declared as static
Properties of static functions are:
• They can access only other STATIC members(functions or
variables) declared in the same class
• They can be called using class name ( instead of its object)
• Eg: class_name::function_name
20
21. class A
{
int no;
static int count; //static member
public:
void set_no()
{
count++;
no=count;
}
void put_no()
{
cout<<“ No is:” <<no;
}
static void put_count() //static member function
accessing static member
{
cout<<endl<<“Count:”
<<count;
}
};
Int A::count;
main()
{
A a1, a2;
a1.set_no();
a2.set_no();
A::put_count();
a1.set_no();
a2.set_no();
A::put_count();
a1.put_no();
a2.put_no();
21
22. ARRAY OF OBJECTS
Array can be created of any datatype
Since a class is also a user defined data-type, array of
objects can be created
Eg: a class Employee is specified. If we have to keep records
of 20 employees in an organization having two departments,
then instead of creating 20 separate variables, we can create
array of objects as follows:
Employee dept1[10];
Employee dept2[10];
22
23. MEMORY ALLOCATION FOR
OBJECTS
Memory space for object is allocated when they are declared and
not when the class is specified
The member functions are created and placed in the memory only
once, when they are defined as a part of a class specification
All the objects belonging to the particular class will use same
member functions when objects are created
However, the data members will hold different values for different
object, so, space for data member is allocated separately for each
object
23
24. OBJECTS AS FUNCTION
ARGUMENTS
Like any other variable, objects can also be passed to the
function, as an argument
There are two ways of doing this
• Pass by value
• Pass by reference
In the pass by value, the copy of the object is passed to the
function
So, the changes made to the object inside the function do not
affect the actual object
24
26. FRIEND FUNCTIONS AND
FRIEND CLASSES
friend declarations
• To declare a friend function
• Type friend before the function prototype in the class
that is giving friendship
friend int myFunction( int x );
should appear in the class giving friendship
• To declare a friend class
• Type friend class Classname in the class that is
giving friendship
• if ClassOne is granting friendship to ClassTwo,
friend class ClassTwo;
• should appear in ClassOne's definition
27. 1 // Fig. 7.5: fig07_05.cpp
2 // Friends can access private members of a class.
3 #include <iostream>
4
5 using std::cout;
6 using std::endl;
7
8 // Modified Count class
9 class Count {
10 friend void setX( Count &, int ); // friend declaration
11 public:
12 Count() { x = 0; } // constructor
13 void print() const { cout << x << endl; } // output
14 private:
15 int x; // data member
16 };
17
18 // Can modify private data of Count because
19 // setX is declared as a friend function of Count
20 void setX( Count &c, int val )
21 {
22 c.x = val; // legal: setX is a friend of Count
23 }
24
25 int main()
26 {
27 Count counter;
28
29 cout << "counter.x after instantiation: ";
30 counter.print();
Changing private variables
allowed.
28. 31 cout << "counter.x after call to setX friend function: ";
32 setX( counter, 8 ); // set x with a friend
33 counter.print();
34 return 0;
35 }
counter.x after instantiation: 0
counter.x after call to setX friend function: 8