0% found this document useful (0 votes)
3 views

Static Member Function in C++

The document discusses various object-oriented programming techniques, focusing on the use of constant and static member functions and variables. It explains the syntax for static member functions, arrays of objects, and how to pass and return objects as arguments in functions. Key points include the limitations of static member functions and the proper way to handle arrays of objects in programming.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Static Member Function in C++

The document discusses various object-oriented programming techniques, focusing on the use of constant and static member functions and variables. It explains the syntax for static member functions, arrays of objects, and how to pass and return objects as arguments in functions. Key points include the limitations of static member functions and the proper way to handle arrays of objects in programming.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 17

Object Oriented

Programming Techniques
Revision
Constant Member Variable Non-Constant Function Possible
Constant Member Variable Non-Constant Object Possible
Constant Member Function Non-Constant Object Possible
Constant Member Function Constant Object Possible
Constant Member Function Non-Constant Object Possible
Constant Object Constant Member Function Possible
Constant Object Non-Constant Member Function Not Possible
Static Member Variable Non-Constant Object Possible
Static Member Variable Static Member Function Possible
Non-Static Member Variable Static Member Function Not Possible
Revision: Static Member Function Key
Points
• A static member function can only access static member data, static
member functions and data and functions outside the class
• You must take note not to use static member function in the same manner
as non-static member function, as non-static member function can access
all of the above including the static data member
• A non-static member function can be called only after instantiating the
class as an object whereas static member functions can be called even
when a class is not instantiated

3
Static Member Function
• Syntax
static returnType functionName() {}
Function call
className ::functionName()
Output
Array of Object
• The Array of Objects stores objects. An array of a class type is also
known as an array of objects

• Syntax:
ClassName ObjectName[number of objects];
• Example:
Employee e[50];
Array of Object

Output
Array of Object
• Other way for array of object with similar output
Array of Object
Output
Dynamically Allocate Array of Object

Output
Passing Object as an Argument
• To pass an object as an argument we write the object name as the
argument while calling the function the same way we do it for other
variables

Syntax:
• function_name(object_name);
Object as Argument

Output
Dry Run for Output
Passing Object as an Argument
Output
Returning Object from Function
Returning
Object from
Function
Output
Passing and Returning
Object from Function

Output

You might also like