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

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
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
