Vote count:
0
Hello I have tried lots of things to my publisher code but i cant seem to get it to store the string that's being sent to it please help me fix it. I looked at the median variables and it just seems to me the those variables are not sending the data to the class members.
class BookType
{
private:
string publisher;
string authors[4];
int tracka;
int copy;
int Booktracker;
public:
BookType()
{
}
void setpub(const std::string &pr)
{
publisher = pr;
}
string getpub()
{
return publisher;
}
void setnumAuthor(int a)
{
tracka = a;
}
void setauthor(const std::string &a, int tracka)
{
for (int tracka; tracka<4; tracka++)
{
authors[tracka] = a;
}
}
void setTBook(int T)
{
Booktracker = T;
}
string getauthor()
{
for (int i = 0; i < 4; i++)
{
return authors[i];
}
}
};
int main()
{
optionmenu();
system("pause");
return 0;
}
void optionmenu()
{
BookType Book[10];
string author;
char choice;
string pub;
cout << "please enter the author(s) name(s), if less then 4 authors leave (NA) in the leftover blanks." << endl;
for (int ai = 0; ai < 4; ai++)
{
getline(cin, author);
Book[i].setnumAuthor(ai);
}
cout << "what is the publisher of the book?" << endl;
getline(cin, nu);
getline(cin, pub);
Book[i].setpub(pub);
asked 38 secs ago
What is wrong with the publisher and author class member storing strings
Aucun commentaire:
Enregistrer un commentaire