0
#include<iostream.h>
#include<string>


class books
{
char  author[20],title[100],publisher[30];
float price;
int stock;


public:
void display();


void getdata(void)
{
char title[100],author[20];
cout<<"Name/Title of the Book--->";
cin>>title;
cout<<"\n\nAuthor of the Book------->";
cin>>author;
}
void stock()
{
char choice='y',another;
while(choice=='y')
{
cout<<"\nEnter the following into Stock....\n";


cout<<"\nAuthor-------->";
cin>>author;


cout<<"\nTitle--------->";
cin>>title;


cout<<"\nPrice--------->";
cin>>price;


cout<<"\nPublisher----->";
cin>>publisher;


cout<<"\nNo of Copies-->";
cin>>stock;


cout<<"\n\nAdd another record(y/n)--->";
fflush(stdin);
another=getche();
//cin>>another;
}
}


void match()
{

in void match()--->I want to match void getdata() and void stock(). How I can do this.
Pls help me

Edited by happygeek: fixed formatting

3
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by MrSpigot
0

wrap this in [code=cpp] [/code] tags, with indents. And what do you mean you "want to match void getdata() and void stock()"?

0

in void match()--->I want to match void getdata() and void stock(). How I can do this.

You have a bit of work to do. In getdata() you are reading the book details into local variables, so match() can't access it. One approach would be to make title[] and author[] into class members (rename them so as not to clash with the existing names). In match() you can then compare your getdata() input with the existing stock.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.