0% found this document useful (0 votes)
7 views2 pages

Comparison Class and Instance Data Members Member Function

Uploaded by

yasoobvogue
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views2 pages

Comparison Class and Instance Data Members Member Function

Uploaded by

yasoobvogue
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Comparison Table of Class data members, member Function v/s

Instance data members, instance member function

Feature Class Data Class Member Instance Data Instance Member


Members Functions Members Functions

Definition Variables Functions defined Variables Functions that


declared within a within a class that unique to each operate on the
class, shared operate on its data instance of a specific instance's
across instances members. class. data members.
if static.

Memory Allocated once Memory allocated Allocated for Allocated for each
Allocation per class (for when the class is each instance instance; operates
static members). instantiated; can when the on that instance's
access data object is data.
members. created.

Access Accessed Called on Accessed only Called only on


through the class instances or through the instances of the
name (for static) through the class instance of the class.
or through an itself (if static). class.
instance. OR
OR OR
OR Using an object of
Using the class Using an object the class
Using the class name of the class
name

Accessed by Class scope Class scope Instance scope Instance scope

Scope Can be private, Can also be Always tied to a Tied to specific


protected, or private, protected, specific object; instances; cannot
public; static or public; control cannot be be shared
members are access to data shared between between
shared across all members. instances. instances.
instances.

Initialization Initialized at class Initialized at class Initialized at Initialized at


definition definition instance instance creation
creation
Usage Define properties Define behaviors Store state Perform
of the class; used or operations that information operations
to store state can be performed unique to each specific to that
information. on the data object of the object's state; can
members. class. modify instance
data members.

Memory Memory Memory allocated Memory Memory allocated


Allocation allocated at class at class definition allocated at at instance
definition instance creation
creation

Purpose To store data To store data that To define To define


that is common is specific to each operations that operations that
to all objects object are shared by are specific to
all objects each object

You might also like