Ace school

with brainly

  • Get help from millions of students
  • Learn from experts with step-by-step explanations
  • Level-up by helping others

A community for students.

class C{ public: int f(int a){return x*a;} protected: int getX(){return x;} private: int x; }; cout<

Computer Science
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Join Brainly to access

this expert answer

SIGN UP FOR FREE
I am not really into programming.......but it seems ok to me
it has many errors
parameters are not properly used in programms

Not the answer you are looking for?

Search for more explanations.

Ask your own question

Other answers:

@thageram I believe he did not write the complete program to save tedious typing
are u calling it in main or in the implementation file
Int getX needs to be public. not protected.
The protected-flag only allows the Object itself and its following generations (classes, which extend this class, inheritance) to access the method. I'm not familiar with C (i guess its C) but for me it looks like thats your problem. Change it to public and it maybe it'll work.
if any data member or member function is declared protected they will be accessible only in the class itself and the inherited class .Further accessibility will depend on the type of inheritance i.e public ,private etc.. To sort this out just make int getX() function public . I suppose that the function cout<
the value of getx is protected in this program there is parameters x is used to pass the value of x but the value of x is private so main cannot execute it he should change it public

Not the answer you are looking for?

Search for more explanations.

Ask your own question