1. It is good practice to initialize private member variables in the function de
ID: 3543046 • Letter: 1
Question
1. It is good practice to initialize private member variables in the function definition of the function they are being used? (T/F).
2. True or false: The operator function as a member of a class has only one parameter; as a nonmember of a class, it has two parameters.
3.Which of the following is not true about overloading an operator?
a) You cannot create new operator
b) You can change the precedence of an operator
c) You cannot change the number of arguments that an operator takes
d) You can overload an operator for objects of the user-defined type
4.True/False. Random access iterators are bidirectional iterators that can randomly process the elements of a container.
5.Write the code to declare a vector of type int, fill three elements, and check to see if the vector is empty
Explanation / Answer
1 . T . Using private members incorporates the Data encapsulation and security breach of the functions variables . Take Bank sites they offer you balance check which will be a private member of a function you cant cange from outside you can just only invoke function for balance which assures data security and encapsulation.
2 . True .
Overloaded operators are functions with special names the keyword operator followed by the symbol for the operator being defined. Like any other function, an overloaded operator has a return type and a parameter list.
declares the addition operator that can be used to add two Box objects and returns final Box object. Most overloaded operators may be defined as ordinary non-member functions or as class member functions. In case we define above function as non-member function of a class then we would have to pass two arguments for each operand as follows:
3.b) You can change the precedence of an operator . Precedence of an operator is not dependent on overloading . Its defined in its own implementation we are just overloading them . we cant change precedence.
4.TRUE . Bidirectional iterators are like forward iterators but can also be iterated through backwards.
5. vector<int> values (5);
values[1] 1;
values[2] 1;
values[3] 1;
values.size()!=0;
return values.size();
values.remove (values.size());
6 . a shallow copy of a collection of two collections , now__________ elements.
A deep copy of a collection of two collections now _________________elements
7 gives Segmentation fault . this can already lead to your harddisk drive being formatted or your computer emerging to a giant, flesh-eating zombie. In reality, it will usually just work. But it's easy to make up a case where the end of the array marks the end of a mapped memory region, so accessing one element beyond would cause a segmentation fault.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.