by Dinesh Thakur Category: Functions

As we Know that For Accessing any thing means Data Members and Member Functions from a Class we must have to Create an Object First, So that When we Creates an Object of Class , then all the Data of Class will be Copied into an Object so that this will Consume Some Memory So that double Memory will be used for Storing the Data of single Class. First, Memory used by Class for storing his data and Second by Object.

So that for Removing the Problem for storing the data and Member Functions twice. We uses the Static and Static Member Functions.

Static Data Members are those which are declared by using the Static Keyword in front of the Data Members. Means Put the Static Keyword in front of the Variables. And Static Data Members always have Default values as\ 0 for int and Null for Strings. So that they will Never Stores any Garbage values. Always remember that Static Data Members are always used in the Static Member Functions. Means if a Member Functions wants to use a Static Data then we must have to declare that Member Function as Static. And the Static Data Members are always Assigned Some values from the outside from the Class.

Static Member Functions: The Static Member Functions are those which are declared by using the Static in Front of the Member Function. And in this we use the Static Data Members.  Any Method can be converted into the Static just by Using the Static in front of the Member Function. 

For Accessing the Static data Member Function we doesn’t need to Create an Object of Class and we will call the Function with the name of Class and Scope resolution Operator.  So that there will be no object and no Extra Memory is required to Store the Data of a Class.

Related Articles on Function in C

About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.C.A, MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.

Related Articles