Thursday, July 30, 2009

Please give me short note of my C++ program...?

Problems are taken from C++ Primer book





-Ensure you can complete prior to accepting and emailing me.





-If you do not provide your price to do this I will not respond…





-I require this completed in 1 week.





Exercise 13.3: Assuming Point is a class type with a public copy constructor, iden¬tify each use of the copy constructor in this program fragment:


Point global;


Point foo_bar(Point arg)


{


Point local = arg;


Point *heap = new Point(global);


*heap = local;


Point pa[ 4 ] = { local, *heap };


return *heap;





______________________________________...





Exercise 13.10: Define an Employee class that contains the employee's name and a unique employee identifier. Give the class a default constructor and a constructor that takes a string representing the employee's name. If the class needs a copy construc¬tor or assignment operator, implement those functions as well.





______________________________________...








Among the fundamental operations a pointer supports are dereference and arrow. We can give our class these operations as follows:


class ScreenPtr { public:


// constructor and copy control members as before


Screen %26amp;operator*() { return *ptr-%26gt;sp; }


Screen *operator-%26gt;() { return ptr-%26gt;sp; }


const Screen %26amp;operator*() const { return *ptr-%26gt;sp; } const Screen *operator-%26gt;() const { return ptr-%26gt;sp; } private:


ScrPtr *ptr; // points to use-counted ScrPtrclass








Exercise 14.20: In our sketch for the ScreenPtr class, we declared but did not define the assignment operator. Implement the ScreenPtr assignment operator.





______________________________________...





Exercise 14.21: Define a class that holds a pointer to a ScreenPtr. Define the over¬loaded arrow operator for that class.


______________________________________...








Exercise 15.4: A library has different kinds of materials that it lends out—books, CDs, DVDs, and so forth. Each of the different kinds of lending material has different check-in, check-out, and overdue rules. The following class defines a base class that we might use for this application. Identify which functions are likely to be defined as virtual and which, if any, are likely to be common among all lending materials. (Note: we assume that LibMember is a class representing a customer of the library, and Date is a class representing a calendar day of a particular year.)


class Library { public:


bool check_out(const LibMemberk);


bool check_in (const LibMember%26amp;);


bool is_late(const Date%26amp; today);


double apply_fine();


ostream%26amp; print(ostream%26amp; = cout);


Date due_date() const;


Date date_borrowed() const;


string title 0 const;


const LibMember%26amp; member() const;





______________________________________...








Exercise 15.8: Given the following classes, explain each print function:


struct base {


string name () { return basenatne; }


virtual void print(ostream %26amp;os) { os « basename; } private:


string basename;


};


struct derived {


void printO { print (ostream %26amp;os) ; os « " " « mem; } private:


int mem;


};





If there is a problem in this code, how would you fix it?





______________________________________...








Exercise 15.13: Given the following classes, list all the ways a member function in Cl might access the static members of ConcreteBase. List all the ways an object of type C2 might access those members.


struct ConcreteBase {


static std::size_t object_count(); protected:


static std::size_t obj_count;


};


struct Cl : public ConcreteBase


{ /* . . .*/};


struct C2 : public ConcreteBase


{ /* ...*/};





______________________________________...





Exercise 15.25: Assume Derived inherits from Base and that Base defines each of the following functions as virtual. Assuming Derived intends to define its own ver¬sion of the virtual, determine which declarations in Derived are in error and specify what's wrong.


(a)Base* Base::copy(Base*);


Base* Derived::copy(Derived*);


(b)Base* Base::copy(Base*) ;


Derived* Derived::copy(Base*) ;


(c)ostreamk Base::print(int, ostream%26amp;=cout);


ostream%26amp; Derived::print(int, ostream%26amp;);


(d)void Base::eval() const;


void Derived::eval();

Please give me short note of my C++ program...?
This kind of stuff, where you pay for someone who codes for you would be best accomplished at http://www.rentacoder.com or http://www.guru.com
Reply:And that is a fact since it goes against community guidelines and rules and will be *REPORTED*.
Reply:looks good to me


No comments:

Post a Comment