Answer the question
In order to leave comments, you need to log in
The code does not refer to the required class, how to fix it?
In the code, as far as I understand, the error is such that it refers to the first written default class, respectively, it does not find functions from other classes that I refer to and throws an error. If suddenly I'm wrong, here is a list of errors.
In function 'int main()':
[Error] conflicting declaration 'Reader symbol [500]'
[Note] previous declaration as 'Bibl symbol [500]'
[Error] conflicting declaration 'Order symbol [500]'
[Note] previous declaration as 'Bibl symbol [500]'
[Error] 'class Bibl' has no member named 'Add_Reader'
[Error] 'class Bibl' has no member named 'Add_Order'
[Error] 'class Bibl' has no member named 'GetReader'
[Error] 'class Bibl' has no member named 'GetOrder'
#include <iostream>
#include <string>
#include <windows.h>
using namespace std;
class Bibl {
private:
string Bibl_name, PIB, adres, otdel; int nomer;
public:
void Add_Bibl(string a, string b, string c, int d, string e) {
Bibl_name = a;
PIB = b;
adres = c;
nomer = d;
otdel = e;
}
void GetBibl() {
cout << "Librarian name: \t" << Bibl_name << endl << "Full name: \t" << PIB << endl << "Address: \t" << adres << endl << "Phone number: \t" << nomer << endl << "The Department: " << otdel << endl;
}
} ;
class Reader {
private:
string Bibl_name_r, PIB_r; int nomer_r, zakaz;
public:
void Add_Reader(string f, string g, int h, int j) {
Bibl_name_r = f;
PIB_r = g;
nomer_r = h;
zakaz = j;
}
void GetReader() {
cout << "Librarian name: \t" << Bibl_name_r << endl << "Full name: \t" << PIB_r << endl << "Phone number: \t" << nomer_r << endl << "Order number: \t" << zakaz << endl;
}
} ;
class Order {
private:
string book, autor, time1, time2; int year;
public:
void Add_Order(string k, string l, string m, string n, int o) {
book = k;
autor = l;
time1 = m;
time2 = n;
year = o;
}
void GetOrder() {
cout << "Book name: \t" << book << endl << "Autor name: \t" << autor << endl << "Year of issue: \t" << year << endl << "Delivery time to the client: \t" << time1 << endl << "Hold time" << time2 << endl;
}
} ;
int main() {
string a, b, c, e; int d;
string f, g; int h, j;
string k, l, m, n; int o;
bool soft = true;
short menu, Bibl_kol, Reader_kol, Order_kol;
Bibl symbol[500];
Reader symbol[500];
Order symbol[500];
while (soft == true) {
system ("cls");
cout << "\t 1) Dobavit bibliotekar" << endl << "\t 2) Dobavit chitatel" << endl << "\t 3) Dobavit zakaz" << endl << "\t 4) Spisok bibl" << endl << "\t 5) Spisok reader" << endl << "\t 6) Spisok zakazov" << endl;
cin >> menu;
if (menu == 1) {
system ("cls");
cout << ("Skolko bibliotekar dobavit? "); cin >> Bibl_kol;
for (int i = 0; i < Bibl_kol; i++) {
system ("cls");
cout << "Librarian name: "; cin >> a, cout << endl;
cout << "Full name: "; cin >> b; cout << endl;
cout << "Address: "; cin >> c; cout << endl;
cout << "Phone number: "; cin >> d; cout << endl;
cout << "The Department: "; cin >> e; cout << endl;
symbol[i].Add_Bibl(a, b, c, d, e);
}
cout << "Dobavleno." << endl;
Sleep (3000);
}
if (menu == 2) {
system ("cls");
cout << ("Skolko reader dobavit? "); cin >> Reader_kol;
for (int i = 0; i < Reader_kol; i++) {
system ("cls");
cout << "Librarian name: "; cin >> f, cout << endl;
cout << "Full name: "; cin >> g; cout << endl;
cout << "Phone number: "; cin >> h; cout << endl;
cout << "Order name: "; cin >> j; cout << endl;
symbol[i].Add_Reader(f, g, h, j);
}
cout << "Dobavleno." << endl;
Sleep (3000);
}
if (menu == 3) {
system ("cls");
cout << ("Skolko zakazov dobavit? "); cin >> Order_kol;
for (int i = 0; i < Order_kol; i++) {
system ("cls");
cout << "Book name: "; cin >> k, cout << endl;
cout << "Autor name: "; cin >> l; cout << endl;
cout << "Year of issue: "; cin >> o; cout << endl;
cout << "Delivery time to the client: "; cin >> m; cout << endl;
cout << "Hold time: "; cin >> n, cout << endl;
symbol[i].Add_Order(k, l, o, m, n);
}
cout << "Dobavleno." << endl;
Sleep (3000);
}
if (menu == 4) {
system ("cls");
for (int i = 0; i < Bibl_kol; i++) {
symbol[i].GetBibl();
Sleep(1000);
}
Sleep (3000);
}
if (menu == 5) {
system ("cls");
for (int i = 0; i < Reader_kol; i++) {
symbol[i].GetReader();
Sleep(1000);
}
Sleep (3000);
}
if (menu == 6) {
system ("cls");
for (int i = 0; i < Order_kol; i++) {
symbol[i].GetOrder();
Sleep(1000);
}
Sleep (3000);
}
}
return 0;
}
Answer the question
In order to leave comments, you need to log in
Variables
Bibl symbol[500];
Reader symbol[500];
Order symbol[500];
must be named differently.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question