Get premium membership and access questions with answers, video lessons as well as revision papers.

Given the following class, show how to add a friend function called isneg() that takes one parameter of type myclass and returns true if num...

      

Given the following class, show how to add a friend function called isneg() that takes one parameter of type myclass and returns true if num is negative and false otherwise.
class myclass {
int num;
public:
myclass(int x) {num = x;}
};

  

Answers


Davis
#include
using namespace std;
class myclass {
im;
public:
myclass(int x) {num= x; }
friend int isneg(myclass ob);
};
int isneg(myclass ob)
{
return (ob.num}
int main()
{
mycl-1) , b(2);
cout <cout << "\n";
return 0;

Githiari answered the question on May 31, 2018 at 17:48


Next: Distinguish between a tactical decision and an operational decision.
Previous: Justify the use of spreadsheets within the finance department

View More Computer Studies Questions and Answers | Return to Questions Index


Learn High School English on YouTube

Related Questions