Get premium membership and access questions with answers, video lessons as well as revision papers.
#include
using namespace std;
class pr2; //forward declaration
class pr1 {
int printing; ...
public:
pr1() {printing = 0; }
void set_print(int status) {printing = status; }
// ...
friend int inuse (pr1 o1, pr2 o2);
};
clr2 {
int printing;
// ...
pr2 () {printing = 0; }
void set_print (int status) { printing = status ; }
// ...
friend int inuse(pr1 o1, pr2 o2;
// Return true if printer is in use.
int inuse(pr1 o1, pr2 o2)
{
if(o1.printing || o2.printing) return 1;
else return 0;
}
int main ()
{
pr
pr2 p2;
if (! inuse(p1, p2)) cout << "Printer idle\n";
cout << "Setting p1 to printing ...\n";
p1.set_print(1);
if (inuse(p1, p2)) cout << "Now, prier in use. \n";
cout << "Turn off p1...\n";
p1.set_print (0);
if(! inuse(p1, p2)) cout << "Printer idle\n";
cout << "Turn on p2...\n";
p2.set_pri);
if (inuse(p1, p2)) cout << "Now, printer in use.\";
return 0;
Githiari answered the question on May 29, 2018 at 17:45
- Given this class;
class planet {
int moons;
double dist_from_sun; // in miles
double diameter;
double mass;
public:
//...
double get_ () { return disfrom_sun; }
};
Create a function called light() using c++...(Solved)
Given this class;
class planet {
int moons;
double dist_from_sun; // in miles
double diameter;
double mass;
public:
//...
double get_ () { return disfrom_sun; }
};
Create a function called light() using c++ language that takes as an argument an object of type planet and returns the number of secos that it takes light from the sun to reach the planet.(Assume that light travels at 186,000 miles per second and that dist_from_sun is specified in miles.)
Date posted: May 29, 2018. Answers (1)
- When an object of a derived class is assigned to another object of the same derived class, is the data associated with the base class...(Solved)
When an object of a derived class is assigned to another object of the same derived class, is the data associated with the base class copied? To find out, use the following two classes and write a program that demonstrates what happens.
class base {
int a;
public:
void load_a(int n) { a= n; }
int ge() { return a;}
};
class derived : public base {
int b;
public:
void load_b(int n) {b=n;}
int get_b() {return b;}
};
Date posted: May 29, 2018. Answers (1)
- Using the stack class, write a function called loadstack() that returns a stack that is already loaded with letters of the alphabet (a-z.). Assign this...(Solved)
Using the stack class, write a function called loadstack() that returns a stack that is already loaded with letters of the alphabet (a-z.). Assign this stack to another object in the calling routine and prove that it contains the alphabet. Be sure to change the stack size so it is large enough to hold the alphabet.
Date posted: May 29, 2018. Answers (1)
- Explain five good programming practices(Solved)
Explain five good programming practices.
Date posted: May 29, 2018. Answers (1)
- List five examples of softwares(Solved)
This is a question based on Introduction to Computer Systems unit in Computer science course
Date posted: May 26, 2018. Answers (1)
- List three categories of operating systems(Solved)
List three categories of operating systems.
Date posted: May 26, 2018. Answers (1)
- As a programmer, what is the significance of the Integrated Development Environment(IDE) in programming?(Solved)
As a programmer, what is the significance of the Integrated Development Environment(IDE) in programming?
Date posted: May 26, 2018. Answers (1)
- As a programmer, briefly explain why comments are used when writing a program(Solved)
As a programmer, briefly explain why comments are used when writing a program.
Date posted: May 26, 2018. Answers (1)
- Define the following terms as used in computer programming: (a.) A compiler (b.) A debugger (c.) An algorithm(Solved)
Define the following terms as used in computer programming: (a.) A compiler (b.) A debugger (c.) An algorithm
Date posted: May 26, 2018. Answers (1)
- What is computer programming?(Solved)
What is computer programming?
Date posted: May 26, 2018. Answers (1)
- Using an example, differentiate a code from a program(Solved)
Using an example, differentiate a code from a program.
Date posted: May 26, 2018. Answers (1)
- Explain three techniques of detecting deadlocks in a computer system(Solved)
Explain three techniques of detecting deadlocks in a computer system.
Date posted: May 16, 2018. Answers (1)
- Explain common types of computer networks(Solved)
Explain common types of computer networks.
Date posted: May 16, 2018. Answers (1)
- What is social Engineering?(Solved)
What is social Engineering?
Date posted: May 16, 2018. Answers (1)
- Explain characteristics of information security within an organization? (Solved)
Explain characteristics of information security within an organization?
Date posted: May 16, 2018. Answers (1)
- Giving examples explain threats to data security(Solved)
Giving examples explain threats to data security.
Date posted: May 16, 2018. Answers (1)
- What is a cyber crime?(Solved)
What is a cyber crime?
Date posted: May 16, 2018. Answers (1)
- Describe the difference between an internal and an external hyperlink(Solved)
Describe the difference between an internal and an external hyperlink
Date posted: May 14, 2018. Answers (1)
- What’s the difference between encoding, encryption, and hashing?
(Solved)
What’s the difference between encoding, encryption, and hashing?
Date posted: May 13, 2018. Answers (1)
- Expand on Claude Shannon’s theorem. Differentiate the term confusion and diffusion as envisaged by Shannon to strengthen crypto-algorithm.(Solved)
Expand on Claude Shannon’s theorem. Differentiate the term confusion and diffusion as envisaged by Shannon to strengthen crypto-algorithm.
Date posted: May 13, 2018. Answers (1)