Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Given the class declaration class x { public: void fun(int n): private: int n: }

ID: 3867445 • Letter: G

Question

Given the class declaration class x { public: void fun(int n): private: int n: }: which line of the following client code causes a compile-time error? X alpha: //Line 1 alpha.fun ();//Line 2 alpha.n = 42;//Line 3 A) line 1 B) line 2 C) line 3 D) lines 1 and 2 E) lines 2 and 3 A class SomeClass has a member function func() that has no parameter 1ist, returns an int value, and does not modify any of the object's data members. Which the following would be the correct function definition for func ()? A) int func () const {//code for the function} B) const int func () {//code for the function} C) SomeClass:: int func() const {//code for the function} D) const int SomeClass:: func() {//code for the function} E) int Someclass:: func() const {//code for the function} If the designer of a C++ class wishes to allow clients inspect but not modify private data, what is the best approach? A) Declare the data to be public, not private. B) Provide an access function as a class member. C) Provide an additional class constructor. D) Do nothing-it is not acceptable to let clients inspect private data. What is the output of the following code fragment if the input value is 4? (Be care here.) int num: int alpha = 10: cin > > num: switch (num) { case 3: alpha++: case 4: alpha = alpha + 2: case 8: alpha = alpha + 3: default: alpha = alpha + 4: } cout

Explanation / Answer

25)
Ans: D)


26)
Ans: E)
int SomeCllass::func() const
{//code for the function}

Among the all the above mentioned is te correct syntax.


27)
Ans:B)Provide an access function class as a class member.

28)

int num;
int alpha = 10;

cin>>num;
swwitch(num)
{
case 3 : alpha++;
case 4 : alpha = alpha + 2;
case 8 : alpha = alpha + 3;
default : alpha = alpha + 4;
}
cout << alpha << endl;

Ans: D) 19

alpha ++ means First use the value of alphha than increased by 1.

So at case 1 : the value alpha doesn't change.

so comes to case 3: it is 12 and at the end of case 4: it is 15 and finally at end of case 8: it is 19.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote