High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
Class-١.pptx vbdbbdndgngngndngnnfndfnngn
1. structs that only contain variables represent the traditional non-object-oriented
programming world, as they can only hold data.
2. In the world of object-oriented programming, we often want our types to not
only hold data, but provide functions that work with the data as well.
In C++, this is typically done via the .
keyword defines a new user-defined type.
struct
class
3. the only significant difference is the public keyword in the class.
declaration does not declare any memory. It only defines what the
class looks like
DateClass today { 2020, 10, 14 }; // declare a variable of class DateClass
Defining a variable of a class we call it instantiating the class.
The variable is called an instance, of the class
A variable of a class type is also called an object.
Instantiating an object (e.g. DateClass today) allocates memory for that object.
Classes can also contain functions.
Functions defined inside of a class are
called member functions ( methods).
Member functions can be defined inside or
outside of the class definition.
4. Function member
When we call “today.print()”, we’re telling the
compiler to call the print() member function,
associated with the today object.
5. Using the “m_” prefix for member
variables helps distinguish member
variables from function parameters or
local variables inside member functions.
when we see an assignment to a
variable with the “m_” prefix we are
changing the state of the class.
Unlike function parameters or local
variables, which are declared within the
function, member variables are declared
in the class definition.
Rule!!!! Name your classes starting with
a capital letter.
6. A class that allocates memory will deallocate it before
being destroyed), but it’s not safe to assume a struct will.
we recommend using the struct keyword for data-only
structures, and the class keyword for defining objects that
require both data and functions to be bundled together.
Classes form the basis for Object-oriented programming
7. Access specifiers determine who has
access to the members that follow the
specifier.
1
public
2
private
3
protected
8. Public members are members of a struct or class that can be accessed from outside of
the struct or class.
Private members are members of a class that can only be accessed by other
members of the class.
All members of a struct are public members by default.
All members of a class are private members by default.
error!!!
9. In general, member variables are usually made private, and member functions are usually
made public.