[prog] Re: C++

wolf wolf at wolfrising.net
Sat Mar 13 01:53:11 EST 2004


Hello : )
Thank you for helping : )
Since getdata() and putdata() are of type void would the correct 
response
between the braces be:

getdata()
{
return getdata;
}

I'm afraid I don't understand this bit at all:
> showdata()
> {
> // use loop with EOF
> // to extract data and display it
> }

how to extract something from type void?
again thank you for helping : )


On Mar 13, 2004, at 12:40 AM, Warren Prasad wrote:

>
> #include <iostream.h>
> //not needed
> //using namespace std;
> FILE *fp;
>  class cdlib
>  {
>    char artist[30];
>    char title[50];
>    int yr;
>    char genre[10];
>  public:
>    void getdata();
>                       void showdata();
>    void putdata();
>  };
>  int main()
>  {
> char ch;
> fp = fopen("library.txt", "+rw");
> ch = 'y';
> while(ch == 'y')
> {
>   getdata();
>   cout << "do you want to enter more data (y/n) : ";
>   cin >> ch;
> }
>
> cout << "do you want to view the data (y/n) : ";
> cin >> ch;
> if (ch == 'y')
> {
>   showdata();
> }
> return 0;
> }
> void getdata()
> {
> // Input each data
> // donot use loop
> putdata()
> // use this to write the data into a file
> }
> showdata()
> {
> // use loop with EOF
> // to extract data and display it
> }
>  
>  
>  
>
>
> wolf <wolf at wolfrising.net> wrote:
> Hi : )
>
> Pretty much the whole thing, I think I bit off more than I can chew : )
> Last time I posted my
> question someone was nice enough to start the class for me, and I've
>  been trying for
> about a week to figure out/follow along how classes work but this is a
> pretty big jump
> from what I've tried before. Any advice, ideas, help is very much
>  appreciated : ) I
> had finally figured out functions but this seems to be a whole new game
>  : )
>
> Thank you!
>
> On Mar 12, 2004, at 10:07 PM, Sue Stones wrote:
>
> > On Sat, 13 Mar 2004 01:24 pm, wolf wrote:
> >> Could anyone help me along with getting this to work? Here's the
> >> original question I'm trying
> >
> > G'day Wolf,
> > Can you be specific about what you are stuck on at the moment?
> > sue
> >
> >
> >> to figure out:
> >>> w! rite a simple program to track an individual's cd library, the
> >>> program should permit the user to enter 10 cds. Each cd
> >>> should contain the following items: artist, album title, year and
> >>> genre. the program should display all the cds in order
> >>> by artist. design a class and represent each album as an object of
> >>> that class. provide the capability to store the data
> >>> in a text file and retrieve it again the next time the program is
> >>> run.
> >>
> >> #include
>  >> using namespace std;
> >>
> >> class cdlib
> >>
> >> {
> >>
> >> char artist[30];
> >>
> >> char title[50];
> >>
> >> int yr;
> >>
> >> char genre[10];
> >>
> >>
> >>
> >> public:
> >>
> >> void getdata();
> >>
> >> void showdata();
> >>
> >&g! t; void putdata();
> >>
> >> };
> >>
> >> int main()
> >> {
> >>
> >> int cd;
> >>
> >> /* get the data from the user and write it down to a text file. use
> >> cin */
> >> while (cd < 10)
> >> {
> >> cout << "Enter the Artist's Name: "<< endl;
> >> cin >> artist;
> >> cout << "Enter the Compact Disk Title: " << endl;
> >> cin >> title;
> >> cout << "Enter the Year the CD was recorded: "<< endl;
> >> cin >> yr;
> >> cout << "Enter the genre for this CD: " << endl;
> >> cin >> genre;
> >> }
> >>
> >> return 0;
> >> }
> >> /* to put data into the file fopen, fwrite */
> >>
> >> putdata()
> >>
> >>
> >> }
> >>
> >>
> >>
> >> getdata()
> >>
> >> {
> >>
> &g! t;> /* Read the data from the file fopen. fread */
> >> return data;
> >> }
> >>
> >> _______________________________________________
> >> Programming mailing list
> >> Programming at linuxchix.org
> >> http://mailman.linuxchix.org/mailman/listinfo/programming
> >
> > _______________________________________________
> > Programming mailing list
> > Programming at linuxchix.org
> > http://mailman.linuxchix.org/mailman/listinfo/programming
> >
>
> _______________________________________________
> Programming mailing list
> Programming at linuxchix.org
> http://mailman.linuxchix.org/mailman/listinfo/programming
>
> Do you Yahoo!?
> Yahoo! Mail - More reliable, more storage, less spam


More information about the Programming mailing list