Question

In: Computer Science

(a) Why can't records use private data members (instead of public). (b) Why shouldn't objects use...

(a) Why can't records use private data members (instead of public).

(b) Why shouldn't objects use public data members?

Solutions

Expert Solution

a) Why can't records use private data members(instead of public)

solution: Private data members cannot access the records outside of class its access only inside class and sometimes break  the private data members access the outside of class crack the implementation of code

public data members: public data members huge increases in accessibility of records occurs and public data members  can easy to change the code

So private data members to implementation is difficult acess the records and records can acess the outside of class thats why can't records use private data members

b) Why should't objects use public data members?

solution: because objects uses the public data members when its possible to changes the values of objects when its entire project code losses that why objects are use private data members

objects use private data members when its constant noone can change the value so its constant values declared as objects best way to implement the code

when its uses const keyword are used to declared the objects

please i kindly requesting upvote rating my answer and i clearly explain the solution is correct please rating my answer


Related Solutions

class A { public: //constructors // other members private: int a; int b; }; Give declatations...
class A { public: //constructors // other members private: int a; int b; }; Give declatations of operator functions for each of the following ways to overload operator + You must state where the declatation goes, whether within the class in the public or private section or outside the class. The operator + may be overloaded. a) as friend function b) as member function c) as non-friend, non-member function
b. Unlike private placement of securities, a public offer often requires the use of an underwriter...
b. Unlike private placement of securities, a public offer often requires the use of an underwriter to make the issue succeed. As a young and dynamic Financial Engineer who has just been employed by the Mayfair Company, a leading producer of building materials in the Republic of Benin, advise your CEO on the availability of the various types of underwriting that you know to enable him/her make a good choice.
b. Unlike private placement of securities, a public offer often requires the use of an underwriter...
b. Unlike private placement of securities, a public offer often requires the use of an underwriter to make the issue succeed. As a young and dynamic Financial Engineer who has just been employed by the Mayfair Company, a leading producer of building materials in the Republic of Benin, advise your CEO on the availability of the various types of underwriting that you know to enable him/her make a good choice.
Why do we use residuals (instead of the data) to check the assumptions in an experimental...
Why do we use residuals (instead of the data) to check the assumptions in an experimental design?
Write a java program that creates a hashtable with 10 objects and 5 data members using...
Write a java program that creates a hashtable with 10 objects and 5 data members using mutator and accessor methods for each data member.
What data source would you use for a market-based valuation of a public company? A private...
What data source would you use for a market-based valuation of a public company? A private company? What do you need to know about the data and your subject company to provide reasonable assurance of comparability? Are there circumstances when a market-based method would be more or less appropriate than a DCF or operating income based method? What are the limitations of a market-based method?
1. All members may be public for this example 2. You will need three data members:...
1. All members may be public for this example 2. You will need three data members: a. An array of 3 doubles to keep the votes b. An array of 3 strings to place the candidates names c. An array of 3 doubles to place the calculates vote breakdown 3. You will need three methods: a. A constructor that receives three strings and sets the names of the candidates to these strings and set all the votes initially to zero....
public class IntNode               {            private int data;            pri
public class IntNode               {            private int data;            private IntNode link;            public IntNode(int data, IntNode link){.. }            public int     getData( )          {.. }            public IntNode getLink( )           {.. }            public void    setData(int data)     {.. }            public void    setLink(IntNode link) {.. }         } All questions are based on the above class, and the following declaration.   // Declare an empty, singly linked list with a head and a tail reference. // you need to make sure that head always points to...
why cinema is a club good instead of a private good ? Isnt cinema rivalrous ?...
why cinema is a club good instead of a private good ? Isnt cinema rivalrous ? when you take a seat in the cinema , others cannot sit on the same seat again .
1. public class MyString { private char[] data; MyString(String string) { data = string.toCharArray(); } public...
1. public class MyString { private char[] data; MyString(String string) { data = string.toCharArray(); } public int compareTo(MyString other) { /* code from HW1 here */ } public char charAt(int i) { return data[i]; } public int length() { return data.length; } public int indexOf(char c) { /* code from HW1 here */ } public boolean equals(MyString other) { /* code from HW1 here */ } /* * Change this MyString by removing all occurrences of * the argument character...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT