#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 3 Years Ago by happygeek: fixed formatting

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

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 article has been dead for over six months. Start a new discussion instead.