Welcome to Dream.In.Code
Become a C++ Expert!

Join 137,264 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,508 people online right now. Registration is fast and FREE... Join Now!




ostream

 
Reply to this topicStart new topic

ostream

allican57
14 Dec, 2006 - 10:20 AM
Post #1

New D.I.C Head
*

Joined: 2 Oct, 2006
Posts: 37


My Contributions
I am working on a class project that I'm stuck on the next step and need a little boost.I have included the direction for this, so you can see where I'm stuck along with my existing code. I'm not asking fo project to be finished. i just ned a little help with cascading ostream Thanks.


//Program (50 points)
//
//43. Create a program meeting the following requirements:
//1. It has a class called Instrument
//2. The class has an overloaded friend stream insertion operator that does the following:
//a. Outputs the instrument Name
//b. Outputs the number of instruments in the band if there are more than zero
//c. Returns the ostream object as a reference to allow cascading
//3. The class has an overloaded friend stream extraction operator that does the following:
//a. Prompts the user to enter the number of instrument’s in the band by the specific Name
//b. Stores the value in the class data member
//c. Returns the istream object as a reference to allow cascading
//4. The class has a public default constructor with a 25 character parameter that does the following:
//a. Defaults the instrument Name to “Saxophone” if another value is not passed in
//b. Dynamically allocates an array of 25 characters
//c. Copies the value passed in to the class’ data member
//d. Initializes the NumberInBand data member to zero
//5. The class has a private character pointer called Name and a private integer called NumberInBand.
//6. In main create two objects and pass “Coronet” into one and let the other be defaulted. Then cout both objects, cin both objects, and then cout both objects again. Use cascading to do this.
//7. The output should look exactly as shown below except for the numbers input by the user.
//
//Instrument Name: Saxophone
//Instrument Name: Coronet
//Enter the number of Saxophone's in the band: 4
//Enter the number of Coronet's in the band: 6
//Instrument Name: Saxophone
//Number in band: 4
//Instrument Name: Coronet
//Number in band: 6

CODE

#include <iostream>
#include <iomanip>

using namespace std;

class Instrument
{
friend ostream &operator<< (ostream&, Instrument&);
friend istream &operator>> (istream&, Instrument&);

public:
    Instrument();
    Instrument(Instrument *);
private:    

};//end of class

User is offlineProfile CardPM
+Quote Post

allican57
RE: Ostream
14 Dec, 2006 - 01:36 PM
Post #2

New D.I.C Head
*

Joined: 2 Oct, 2006
Posts: 37


My Contributions
Dont everybody jump at once!!!!
User is offlineProfile CardPM
+Quote Post

realNoName
RE: Ostream
14 Dec, 2006 - 09:32 PM
Post #3

D.I.C Regular
***

Joined: 4 Dec, 2006
Posts: 300



Thanked: 5 times
My Contributions
as for cascading ostream you have it setup right
User is online!Profile CardPM
+Quote Post

allican57
RE: Ostream
15 Dec, 2006 - 08:01 AM
Post #4

New D.I.C Head
*

Joined: 2 Oct, 2006
Posts: 37


My Contributions
QUOTE(realNoName @ 14 Dec, 2006 - 10:32 PM) *

as for cascading ostream you have it setup right

Thank You
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/4/08 07:21PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month