我有以下设置:
main.cpp中:
int main()
{
vector <Tour> tourList;
Tour* tour_ptr;
for (unsigned int i = 0; i < tourList.size(); i++)
{
tour_ptr = &tourList[i];
tour_ptr->display();
}
}
Run Code Online (Sandbox Code Playgroud)
Tour.h:
class Tour
{
public:
virtual void display();
};
Run Code Online (Sandbox Code Playgroud)
Tour.cpp:
void Tour::display()
{
cout << "Tour ID: " << getID() << "\n";
cout << "Description: " << getdescription() << "\n";
cout << "Tour Fee: $" << getfee() << "\n";
cout << "Total Bookings: " << getbookings() << "\n\n";
}
Run Code Online (Sandbox Code Playgroud)
GuidedTour.h:
class GuidedTour : …Run Code Online (Sandbox Code Playgroud) 尝试编译以下函数时出现以下错误:
Error: invalid operands of types int and const char [3] to binary operator
Run Code Online (Sandbox Code Playgroud)
我该如何解决?
string getFormattedDate()
{
formattedDate = Date.getDay() << "/" << Date.getMonth() << "/" << Date.getYear();
return formattedDate;
}
Run Code Online (Sandbox Code Playgroud)