我正在编写一个控制台应用程序,它接收产品的净价格并打印出总价格,在处理 main 时,我可以遇到一个问题,我expression must have integral or unscoped enum type在线路cout << "Software costs " + product[0]->getGrossPrice();和cout << "Book costs " + product[1]->getGrossPrice();
这是我到目前为止写的内容:
#include "Software.h"
#include "Book.h"
#include "Product.h"
#include <vector>
#include <iostream>
using namespace std;
int main() {
double price;
vector<Product*> product(8);
Software *software;
Book *book;
cout << "Enter price of software";
cin >> price;
product[0] = new Software(price);
cout << "Software costs " + product[0]->getGrossPrice();
cout << "Enter price of book";
cin >> price;
product[1] = new Book(price);
cout << "Book costs " + product[1]->getGrossPrice();
任何帮助将不胜感激~