Gives an error Error LNK2019 link to an unresolved external symbol "public: void __thiscall tickets :: scan (class std :: basic_ifstream> &)" (? Scan @ tickets @@ QAEXAAV? $ Basic_ifstream @ DU? $ Char_traits @ D @ std @@ @std @@@ Z) in the function "public: void __thiscall ListTickets :: Read (class std :: basic_string, class std :: allocator>)" (? Read @ ListTickets @@ QAEXV? $ basic_string @ DU? $ char_traits @ D @ std @@ V? $ Allocator @ D @ 2 @@ std @@@ Z)

#include "ListTickets.h" #include <iostream> #include <fstream> //#include "tickets.h" using namespace std; ListTickets::ListTickets(unsigned int size) { max_tickets = size; ticket = new tickets[size]; num_tickets = 0; cout << "Вызвана конструкция класса" << endl; cout << "Выделенно объектов - " << max_tickets << endl; cout << "Загруженно книг - " << num_tickets << endl; } ListTickets::~ListTickets() { max_tickets = 0; delete[] ticket; num_tickets = 0; cout << "\n Вызван дестурктор класса ListTickets:"; cout << "\n выделенная память освобожденна "; } void ListTickets::Add_Ticket(tickets aticket) { if (num_tickets <= max_tickets) { ticket[num_tickets] = aticket; num_tickets++; } } void ListTickets::Read(string list)//Чтение книг из файла { ifstream infile; infile.open(list); int size = 0; infile >> size; //infile.get(); cout << size; //tickets aticket; for (int i = 0; i < size; i++) { //ticket[i].tickets::scan(infile); tickets new_ticket; new_ticket.scan(infile); Add_Ticket(new_ticket); } } Фрагмент tickets.cpp #include "tickets.h" #include <iostream> //#include <fstream> using namespace std; void tickets::scan(ifstream &file) { file >> train >> station1 >> station2 >> dep_day >> dep_time >> coach >> seat >> price; } void tickets::display() { cout << "===============================" << endl; cout << "Train: " << train << endl; cout << "Station1: " << station1 << endl; cout << "Station2: " << station2 << endl; cout << "Dep_day: " << dep_day << endl; cout << "Dep_time: " << dep_time << endl; cout << "Coach " << coach << endl; cout << "Seat " << seat << endl; cout << "Price " << price << endl; } float tickets::MaxTicket() { return price; } string tickets::TrainNumber() { return train; } string tickets::Time() { return dep_time; } int tickets::CoachNumber() { return coach; } void tickets::write_to(ofstream &file) { string train_, station1_, station2_, dep_day_, dep_time_; int coach_, seat_, price_; cout << "Enter Train...price"; cin >> train_; cin >> station1_; cin >> station2_; cin >> dep_day_; cin >> dep_time_; cin >> coach_; cin >> seat_; cin >> price_; file << train_ << station1_ << station2_ << dep_day_ << dep_time_ << coach_ << seat_ << price_; } 
  • Error in the fragment of the method void ListTickets :: Read (string list) - Andrey Mavrin
  • I have a suspicion that something is wrong in the tickets.h file. What is the access modifier for the scan method? - Modus
  • @Modus public, there were no problems with tickets.h before adding a new class. - Andrei Mavrin
  • @Modus if it is suddenly interesting, I moved the line "#include" ListTickets.h under all includ 's and it all worked. - Andrei Mavrin

1 answer 1

In ListTicket.cpp, I moved the line "#include" ListTickets.h under all of includ 's and it all worked.