Question

#ifndef PROCESSREQUESTRECORD_CLASS #define PROCESSREQUESTRECORD_CLASS #include <iostream> #include <string> using namespace std; class procReqRec { public: //...

#ifndef PROCESSREQUESTRECORD_CLASS
#define PROCESSREQUESTRECORD_CLASS

#include <iostream>
#include <string>

using namespace std;

class procReqRec
{
        public:
                // default constructor
                procReqRec()
                {}

                // constructor
                procReqRec(const string& nm, int p);

                // access functions
                int getPriority();
                string getName();

                // update functions
                void setPriority(int p);
                void setName(const string& nm);

                // for maintenance of a minimum priority queue
                friend bool operator< (const procReqRec& left,
                        const procReqRec& right);

                // output a process request record in the format
                //   name: priority
                friend ostream& operator<< (ostream& ostr,
        const procReqRec& obj);

        private:
                string name;    // process name
                int priority;   // process priority
};

#endif  // PROCESSREQUESTRECORD_CLASS
0 0
Add a comment Improve this question Transcribed image text
Answer #1

#ifndef PROCESSREQUESTRECORD_CLASS

#define PROCESSREQUESTRECORD_CLASS

#include <iostream>

#include <string>

using namespace std;

class procReqRec

{

public:

// default constructor

procReqRec()

{}

// constructor

procReqRec(const string& nm, int p);

// access functions

int getPriority();

string getName();

// update functions

void setPriority(int p);

void setName(const string& nm);

// for maintenance of a minimum priority queue

friend bool operator< (const procReqRec& left,

const procReqRec& right);

// output a process request record in the format

// name: priority

friend ostream& operator<< (ostream& ostr,

const procReqRec& obj);

private:

string name; // process name

int priority; // process priority

};

#endif // PROCESSREQUESTRECORD_CLASS

procReqRec.cpp

#include"procReqRec.h"

// constructor

procReqRec::procReqRec(const string& nm, int p)

{

name=nm;

priority=p;

}

// access functions

int procReqRec:: getPriority()

{

return priority;

}

string procReqRec:: getName()

{

return name;

}

// update functions

void procReqRec::setPriority(int p)

{

priority=p;

}

void procReqRec::setName(const string& nm)

{

name=nm;

}

ostream& operator<< (ostream& ostr,const procReqRec& obj)

{

return ostr<<obj.name<<":"<<obj.priority;

}

bool operator < (const procReqRec& left,const procReqRec& right)

{

return left.priority< right.priority;

}

main.cpp for testing

#include"procReqRec.h"

using namespace std;

int main()

{

procReqRec p1("process1",5);

procReqRec p2("process2",10);

cout<<p1<<endl;

cout<<p2<<endl;

if(p1<p2)

cout<<"\n\nPriority of p1 is less then priority of p2"<<endl;

else

cout<<"\n\nPriority of p1 is greater then priority of p2"<<endl;

return 0;

}

output

If you have any query regarding the code please ask me in the comment i am here for help you. Please do not direct thumbs down just ask if you have any query. And if you like my work then please appreciates with up vote. Thank You.

Add a comment
Know the answer?
Add Answer to:
#ifndef PROCESSREQUESTRECORD_CLASS #define PROCESSREQUESTRECORD_CLASS #include <iostream> #include <string> using namespace std; class procReqRec { public: //...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • lex.h ----------------- #ifndef LEX_H_ #define LEX_H_ #include <string> #include <iostream> using std::string; using std::istream; using std::ostream;...

    lex.h ----------------- #ifndef LEX_H_ #define LEX_H_ #include <string> #include <iostream> using std::string; using std::istream; using std::ostream; enum Token { // keywords PRINT, BEGIN, END, IF, THEN, // an identifier IDENT, // an integer and string constant ICONST, RCONST, SCONST, // the operators, parens, semicolon PLUS, MINUS, MULT, DIV, EQ, LPAREN, RPAREN, SCOMA, COMA, // any error returns this token ERR, // when completed (EOF), return this token DONE }; class LexItem { Token token; string lexeme; int lnum; public: LexItem()...

  • I need help with those two functions c++ #ifndef TRIPLE_H #define TRIPLE_H #include <iostream> #include <string>...

    I need help with those two functions c++ #ifndef TRIPLE_H #define TRIPLE_H #include <iostream> #include <string> using namespace std; class Triple { private: int a, b, c; public: Triple(); // all elements have value 0 Triple(int k); // all elements have value k Triple(int x, int y, int z); // specifies all three elements Triple(string s); // string representation is "(a,b,c)" string toString(); // create a string representation of the vector void fromString(string s); // change the vector to equal...

  • #include <iostream> #include <string> #include "hashT.h" #include "stateData.h" using namespace std; void stateData::setStateInfo(string sName, string sCapital,...

    #include <iostream> #include <string> #include "hashT.h" #include "stateData.h" using namespace std; void stateData::setStateInfo(string sName, string sCapital,    double stArea, int yAdm, int oAdm) {    stateName = sName; stateCapital = sCapital; stArea = stateArea; yAdm = yearOfAdmission; oAdm = orderOfAdmission;       } void stateData::getStateInfo(string& sName, string& sCapital,    double& stArea, int& yAdm, int& oAdm) {    sName = stateName; sCapital = stateCapital; stArea = stateArea; yAdm = yearOfAdmission; oAdm = orderOfAdmission;       } string stateData::getStateName() { return stateName;...

  • Need to implement Account.cpp and AccountManager.cpp code //Account.hpp #ifndef _ACCOUNT_HPP_ #define _ACCOUNT_HPP_ #include <string> using std::string;...

    Need to implement Account.cpp and AccountManager.cpp code //Account.hpp #ifndef _ACCOUNT_HPP_ #define _ACCOUNT_HPP_ #include <string> using std::string; class Account { public: Account(); Account(string, double); void deposit(double); bool withdraw(double); string getName() const; double getBalance() const; private: string name; double balance; }; #endif ////////////////////////////////////////////// //AccountManager.hpp #ifndef _ACCOUNT_MANAGER_HPP_ #define _ACCOUNT_MANAGER_HPP_ #include "Account.hpp" #include <string> using std::string; class AccountManager { public: AccountManager(); AccountManager(const AccountManager&); //copy constructor void open(string); void close(string); void depositByName(string,double); bool withdrawByName(string,double); double getBalanceByName(string); Account getAccountByName(string); void openSuperVipAccount(Account&); void closeSuperVipAccount(); bool getBalanceOfSuperVipAccount(double&) const;...

  • USING THIS CODE: #include <iostream> #include <string> using namespace std; class Contact { //this class cannot...

    USING THIS CODE: #include <iostream> #include <string> using namespace std; class Contact { //this class cannot be viewed from outside of the private class. //only the class functions within the class can access private members. private: string name; string email; string phone; //the public class is accessible from anywhere outside of the class //however can only be within the program. public: string getName() const { return name; } void setName(string name) { this->name = name; } string getEmail() const {...

  • In C++ ***//Cat.h//*** #ifndef __Cat_h__ #define __Cat_h__ #include <string> using namespace std; struct Cat { double...

    In C++ ***//Cat.h//*** #ifndef __Cat_h__ #define __Cat_h__ #include <string> using namespace std; struct Cat { double length; double height; double tailLength; string eyeColour; string furClassification; //long, medium, short, none string furColours[5]; }; void initCat (Cat&, double, double, double, string, string, const string[]); void readCat (Cat&); void printCat (const Cat&); bool isCalico (const Cat&); bool isTaller (const Cat&, const Cat&); #endif ***//Cat.cpp//*** #include "Cat.h" #include <iostream> using namespace std; void initCat (Cat& cat, double l, double h, double tL, string eC,...

  • Please show me how to overload the operators << and >> #ifndef LINK_LIST #define LINK_LIST #include...

    Please show me how to overload the operators << and >> #ifndef LINK_LIST #define LINK_LIST #include <iostream> using namespace std; template <typename T> struct Int_Node {    T value;    Int_Node<T> *pre, *next; }; template <typename T> class Link_List {    template <typename U>    friend ostream &operator<<(ostream &, const Link_List<U> &);// print all integers in the list    template <typename U>    friend istream &operator>>(istream &, Link_List<U> &);// input a value at the back of the list, like insert_node(val);...

  • CODES: main.cpp #include <iostream> #include <string> #include "ShoppingCart.h" using namespace std; char PrintMenu() { char answer;...

    CODES: main.cpp #include <iostream> #include <string> #include "ShoppingCart.h" using namespace std; char PrintMenu() { char answer; cout << "MENU" << endl; cout << "a - Add item to cart" << endl; cout << "d - Remove item from cart" << endl; cout << "c - Change item quantity" << endl; cout << "i - Output items' descriptions" << endl; cout << "o - Output shopping cart" << endl; cout << "q - Quit" << endl << endl; while (true) {...

  • /* FILE: ./shapes7/shape.h */ #include <iostream> using std::ostream; class shape{ int x,y; public: shape( ) {...

    /* FILE: ./shapes7/shape.h */ #include <iostream> using std::ostream; class shape{ int x,y; public: shape( ) { x=y=0;} shape(int xvalue, int yvalue); void setShape(int new_x, int new_y); void setX(int new_x); void setY(int new_y); int getX( ) const; int getY( ) const; virtual void move(int x, int y) = 0; virtual void shift(int dx, int dy) = 0; virtual void draw( ) = 0; virtual void rotate(double r) = 0; virtual void print(ostream&)const; friend ostream & operator<<(ostream & os, const shape& s);...

  • / Animal.hpp #ifndef ANIMAL_H_ #define ANIMAL_H_ #include <string> class Animal { public: Animal(); Animal(std::string, bool domestic=false,...

    / Animal.hpp #ifndef ANIMAL_H_ #define ANIMAL_H_ #include <string> class Animal { public: Animal(); Animal(std::string, bool domestic=false, bool predator=false); std::string getName() const; bool isDomestic() const; bool isPredator() const; void setName(std::string); void setDomestic(); void setPredator(); protected: // protected so that derived class can directly access them std::string name_; bool domestic_; bool predator_; }; #endif /* ANIMAL_H_ */ //end of Animal.h // /////////////////////////////////////////////////////////////////Animal.cpp #include "Animal.h" Animal::Animal(): name_(""),domestic_(false), predator_(false){ } Animal::Animal(std::string name, bool domestic, bool predator): name_(name),domestic_(domestic), predator_(predator) { } std::string Animal::getName() const{ return...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT