我得到这2个文件现在和任何时候我想编译我得到字符串不会在Bestellung.h行命名类型错误行std :: string name;为什么? THX main.cpp中std :: sting?字符串没有命名类型错误
#include "Bestellung.h"
#include <iostream>
using namespace std;
int main()
{
Bestellung();
cout << Bestellung{"maki"} << endl;// [maki,10€]
return 0;
}
Bestellung.cpp
#include "Bestellung.h"
Bestellung(string bestellV,double preisV=10){
name="bestell V";
preis="preis V";
};
string get_name const(Bestellung v) {
return Bestellung.name;
};
double get_preis const(Bestellung v){
return Bestellung.preis;
};
ostream& print(ostream&) const{
};
Bestellung.h
#ifndef BESTELLUNG_H
#define BESTELLUNG_H
#include <string>
#include <iostream>
class Bestellung{
private:
std::string name;
std::double preis;
public:
Bestellung(string,double=10);
string get_name const {
};
double get_preis const{
};
ostream& print(ostream&) const{
};
};
#endif
几个地方在“bestellung.h”你没有使用'std ::'在需要的地方 –