Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

closed What will be the result of the following code?

0 votes
asked Jun 13, 2019 by mark (220 points)
closed Jun 15, 2019 by Admin
#include <iostream>

using namespace std;

class sample

{

private:

    double a,b,c;

public:

    double sample(double x, double y, double z)

    {

        a=x;

        b=y;

        c=z;

    }

double getsum()

 {

   return a+b+c;

 }

};

int main () {

double s;

sample testclass(2,3,4);

s = testclass.getsum();

cout<<s;

return 0;

}

1) 9       2) 4       3) Error in the code.       4) 7
closed with the note: Closing question since already solved.

8 Answers

0 votes
answered Jun 13, 2019 by anonymous
3 becase i know that
+1 vote
answered Jun 13, 2019 by Sadikul Islam (160 points)

 3) Error in the code.  

+1 vote
answered Jun 13, 2019 by anonymous
3) Error in Code

Public class cannot access members of private class
0 votes
answered Jun 13, 2019 by Mahesh
9 is the correct Answer
0 votes
answered Jun 14, 2019 by skboss
error in the code in 15th line
0 votes
answered Jun 14, 2019 by arya nair (140 points)
error in code
0 votes
answered Jun 14, 2019 by anonymous
error in the code
0 votes
answered Jun 14, 2019 by sai naidu (140 points)

.3

private:

    double a,b,c;

Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...