answersLogoWhite

0


Best Answer

The only time you should calculate it instead of storing is when you only use that attribute once. Otherwise, store it to avoid repeating calculations.

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: When is it good idea to calculate an object's attribute on the fly rather than storing it as a data member?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What is the difference between an attribute and a behavior in c plus plus?

An attribute is a class member variable while a behaviour is a class member method.


How do you call 2 or more objects in c plus plus?

It's not clear what you mean by "call 2 or more objects". Object's aren't "called", they are instantiated. Once instantiated you may "call" (invoke) the member methods associated with those objects, or invoke functions that operate upon those objects. To invoke the same member method on 2 or more objects, simply place those objects in a vector (by reference), then iterate over the vector: void f (std::vector<my_object*> objects) { for (auto foo : objects) foo->bar(); // invoke the bar method for each foo object in objects }


What are read only objects in c plus plus?

Read-only objects are those that have private immutable member variables with public accessors (getters) but no public mutators (setters). The object members are typically initialised during construction, but the member variables cannot be altered thereafter, thus they are read-only.


What is the difference between static data member and ordinary data member?

Static data is data that does not change from program load to program exit. Static data member do not apply for c. In c++, a static data member is one that is common for all instances of that class.


What may be different for all objects in a class and what remains the same in C plus plus programming?

The only things that may be different for all objects of a class are their member variables. They represent the object's data. The only things that remain the same are the static members -- they are akin to global variables, but are local to all objects of the class type.

Related questions

What is the difference between an attribute and a behavior in c plus plus?

An attribute is a class member variable while a behaviour is a class member method.


What is wavern's attribute?

Wavern is Drago's love interest and it does not have any attribute. Members of "The White Ones" have no attributes and Wavern is also a member of this group.


Where do you get a Members Only jacket?

Become a member for thousands of Member-only objects.


What is the best attribute of the Adwords service?

Money, the chance to sell, promote and advertise the product is the best attribute, its a bargain for individuals to attack their target audience via Google with their massive member usage.


What are the Java Data Objects standards?

Member Variables


What do you call an objects in a set?

An element or member of the set.


Is there any way for a non-member to trade members objects with a member?

As of now there is no way to do what was asked.


How are the members in the linked list liked together?

Usually each member has a pointer storing the address of the next element.


Can cagr be calculate without a calculator?

Only if you are a member of Mensa


How do you calculate Days per 1000 members?

(days/member months)*12000


How do you call 2 or more objects in c plus plus?

It's not clear what you mean by "call 2 or more objects". Object's aren't "called", they are instantiated. Once instantiated you may "call" (invoke) the member methods associated with those objects, or invoke functions that operate upon those objects. To invoke the same member method on 2 or more objects, simply place those objects in a vector (by reference), then iterate over the vector: void f (std::vector<my_object*> objects) { for (auto foo : objects) foo->bar(); // invoke the bar method for each foo object in objects }


Why was 2060 chiron famous?

It was the first known member of a new class of objects known as centaurs.