我是c ++的新手,在ubuntu上使用eclipse cdt并在我的头文件中出现此错误:
initializing argument 1 of 'std::map<basic_string<char>,Supplier*> Engine::processSupplierFile(char*)' [-fpermissive]
我已经搜索过此错误并发现了这个: Why am I getting error: initializing argument 1 of 'Item::Item(int)' [-fpermissive] in Eclipse when I try to compile my C++ code?
但它没有关于头文件错误的任何答案。
这里是头文件的代码:( Supplier是一个包含两个字符串和一个double的简单对象)
#ifndef Engine_H_
#define Engine_H_
#include "Ingredient.h"
#include "Product.h"
#include "Supplier.h"
#include <stdio.h>
#include <iostream>
#include <string>
#include <sstream>
#include <fstream>
#include <map>
#include <algorithm>
#include <vector>
using namespace std;
class Engine {
public:
Engine();
virtual ~Engine();
string fileToString(string fileName);
void processLoggerFile (char* fileName);
string fileToString(char* fileName);
vector<Product> processProductsFile(char* fileName, const map<string, Ingredient> &cheapestIngredients);
map<string, Supplier*> processSuppliersFile(char* fileName); // this line produces the error
map<string, Ingredient> findCheapestPrices(vector<Supplier> &suppliers);
map<string, Product*> createMenu(vector<Product>& products);
void supplierPriceChange(vector<Product>& products, map<string,Product*>& menu,vector<Supplier>& suppliers, map<string, Ingredient> cheapestIngredients, string supName, string ingName, double newPrice);
};
#endif /* Engine_H_ */
有谁知道导致此错误的原因是什么? 提前谢谢
编辑(supplier.h添加)
/*
* Supplier.h
*
* Created on: Nov 10, 2013
* Author: tom
*/
#ifndef SUPPLIER_H_
#define SUPPLIER_H_
#include <string>
using namespace std;
class Supplier {
public:
Supplier();
Supplier(const Supplier& supplier);
Supplier(string supName, string ingName, double price);
Supplier& operator=(const Supplier& supplier);
virtual ~Supplier();
string getSupplierName() const;
string getIngredientName() const;
double getPrice() const;
void setPrice(double price);
private:
string _ingredientName;
string _supplierName;
double _price;
};
#endif /* SUPPLIER_H_ */
答案 0 :(得分:3)