Q:

What is a static class member? What are the advantages of static members? How do they differ from ordinary members

0

What is a static class member? What are the advantages of static members? How do they differ from ordinary members?

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

A `static` class member is a member that is associated with the class, rather than with individual objects of the class type. It exists outside any object of the class.

Advantages:

- Storage efficient.

- If a `static` member of a class changes, each object of the class will use the new value of that `static` member.

- A `static` data member can have incomplete type.

- A `static` member (either a data member or a member function) can be used as a default argument.

Differences between ordinary members and `static` members:

- A `static` member belongs to the class, an ordinary member belongs to objects of the class.

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now