Trusted by millions of Kenyans
Study resources on Kenyaplex

Get ready-made curriculum aligned revision materials

Exam papers, notes, holiday assignments and topical questions – all aligned to the Kenyan curriculum.

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

Answer Attachments

Exams With Marking Schemes

Related Questions