Join Our WhatsApp Group Join Subscribe Now!

OOP 313304 Practical No.8: Write program to Implement Static Data Member

OOP 313304 Practical No.8: Write a program to Implement Static Data Member

 OOP 313304 Practical No.8: Write a program to Implement Static Data Member

A typical use of static members is for recording data common to all class objects. The static data member is used as a counter to store the number of objects created by a particular class type.

OOP 313304 Practical No.8

Static data members are class members who are declared to be using static keywords. A static
member has certain special characteristics which are as follows: Only one copy of that member is created for the entire class and is shared by all the objects of that class, no matter how many objects are created.
  • It is initialized before any object of this class is created, even before the main starts.
  • It is visible only within the class, but its lifetime is the entire program.

OOP 313304 Practical No.8 Exercise:

1. Write a Program to define a class having data members principal, duration, and rate of interest. Declare rate _of_ interest as static member variable .calculate the simple interest and display it.

Answer: 


Practical Related Questions

1. Write a Program to calculate the weight of objects at different planets using the formula weight=m*g Where m=mass of object G=gravitational force Declare g as a static member variable.

Answer:


2. Complete the following table:

Answer:


Conclusion

We completed OOP 313304 Practical No.8 in which we successfully wrote a C++ program to Implement Static Data Member.

About the Author

Hi everyone, I'm Suraj Diware, and I'm passionate about helping students succeed in MSBTE programs. This blog is dedicated to providing clear and concise explanations of MSBTE curriculum topics, along with practical tips and resources to sup…

Post a Comment

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.