我有
错误C3861:'_ crt_va_end':找不到标识符
以及
IntelliSense:标识符“_crt_va_end”:未找到标识符
我不知道该怎么做,所以我发布了我的整个项目,希望有人能帮助我。
这是我的代码:
#ifndef PRODUCT_H
#define PRODUCT_H
#include<string>
using namespace std;
class Product{
private:
string name;
string brand;
int availability;
static double totalSale;
public:
Product(string = "", string = "", int = 0);
virtual ~Product();
Product & setName(string);
Product & setBrand(string);
Product & setAvailabilty(int);
string getName() const;
string getBrand() const;
int getAvailability() const;
static void addTotalSale(double);
static double getTotalSale();
virtual double calculatePayment(int) = 0;
virtual double calculateTax(int) = 0;
virtual double calculateCost(int) = 0;
};
#endif
#include"Product.h"
double Product::totalSale = 0;
Product::Product(string pName, string pBrand, int quantity){
setName(pName);
setBrand(pBrand);
setAvailabilty(quantity);
}
Product::~Product(){
}
Product & Product::setName(string pName){
name = pName;
return *this;
}
Product & Product::setBrand(string pBrand){
brand = pBrand;
return *this;
}
Product & Product::setAvailabilty(int quantity){
availability = quantity;
return *this;
}
string Product::getName() const{
return name;
}
string Product::getBrand() const{
return brand;
}
int Product::getAvailability() const{
return availability;
}
void Product::addTotalSale(double amount){
totalSale += amount;
}
double Product::getTotalSale(){
return totalSale;
}
#ifndef SMOKING_H
#define SMOKING_H
#include"Product.h"
class Smoking : public Product{
private:
double price;
const double taxPercentage;
public:
Smoking(string = "", string = "", int = 0, double = 0, double = 0);
~Smoking();
Smoking & setPrice(double);
double getPrice() const;
double getTaxPercentage() const;
double calculatePayment(int) override;
double calculateTax(int) override;
double calculateCost(int) override;
};
#endif
#include"Smoking.h"
Smoking::Smoking(string pName, string pBrand, int quantity, double fPrice, double tax)
: Product(pName, pBrand, quantity), taxPercentage(tax){
setPrice(fPrice);
}
Smoking::~Smoking(){
}
Smoking & Smoking::setPrice(double fPrice){
price = fPrice;
return *this;
}
double Smoking::getPrice() const{
return price;
}
double Smoking::getTaxPercentage() const{
return taxPercentage;
}
double Smoking::calculatePayment(int quantity){
return quantity * getPrice();
}
double Smoking::calculateTax(int quantity){
return calculatePayment(quantity) * getTaxPercentage() / 100;
}
double Smoking::calculateCost(int quantity){
Product::addTotalSale(calculatePayment(quantity));
return calculatePayment(quantity) + calculateTax(quantity);
}
#ifndef FOOD_H
#define FOOD_H
#include"Product.h"
class Food : public Product{
private:
double price;
const double taxPercentage;
public:
Food(string = "", string = "", int = 0, double = 0, double = 0);
~Food();
Food & setPrice(double);
double getPrice() const;
double getTaxPercentage() const;
double calculatePayment(int) override;
double calculateTax(int) override;
double calculateCost(int) override;
};
#endif
#include"Food.h"
Food::Food(string pName, string pBrand, int quantity, double fPrice, double tax)
: Product(pName, pBrand, quantity), taxPercentage(tax){
setPrice(fPrice);
}
Food::~Food(){
}
Food & Food::setPrice(double fPrice){
price = fPrice;
return *this;
}
double Food::getPrice() const{
return price;
}
double Food::getTaxPercentage() const{
return taxPercentage;
}
double Food::calculatePayment(int quantity){
return quantity * getPrice();
}
double Food::calculateTax(int quantity){
return calculatePayment(quantity) * getTaxPercentage() / 100;
}
double Food::calculateCost(int quantity){
Product::addTotalSale(calculatePayment(quantity));
return calculatePayment(quantity) + calculateTax(quantity);
}
#ifndef ALCOHOL_H
#define ALCOHOL_H
#include"Product.h"
class Alcohol : public Product{
private:
double price;
const double taxPercentage;
public:
Alcohol(string = "", string = "", int = 0, double = 0, double = 0);
~Alcohol();
Alcohol & setPrice(double);
double getPrice() const;
double getTaxPercentage() const;
double calculatePayment(int) override;
double calculateTax(int) override;
double calculateCost(int) override;
};
#endif
#include"Alcohol.h"
Alcohol::Alcohol(string pName, string pBrand, int quantity, double fPrice, double tax)
: Product(pName, pBrand, quantity), taxPercentage(tax){
setPrice(fPrice);
}
Alcohol::~Alcohol(){
}
Alcohol & Alcohol::setPrice(double fPrice){
price = fPrice;
return *this;
}
double Alcohol::getPrice() const{
return price;
}
double Alcohol::getTaxPercentage() const{
return taxPercentage;
}
double Alcohol::calculatePayment(int quantity){
return quantity * getPrice();
}
double Alcohol::calculateTax(int quantity){
return calculatePayment(quantity) * getTaxPercentage() / 100;
}
double Alcohol::calculateCost(int quantity){
Product::addTotalSale(calculatePayment(quantity));
return calculatePayment(quantity) + calculateTax(quantity);
}
#include"Food.h"
#include"Smoking.h"
#include"Alcohol.h"
#include<vector>
#include<iostream>
using namespace std;
int main(){
vector<Product *> product;
Smoking smoke("Cigarret","Winston",5,100,100);
Alcohol alcohol("Cogniac","Ararat",10,200,50);
Food food("Drinks","Water",20,1.25,1);
product.push_back(&alcohol);
product.push_back(&food);
product.push_back(&smoke);
for(unsigned i = 0; i < product.size(); ++i)
cout << product[i]->getName() << endl << product[i]->getBrand() << endl
<< product[i]->getAvailability() << endl << product[i]->calculatePayment(1)
<< endl << product[i]->calculateTax(1) << endl <<
product[i]->calculateCost(1) <<
endl << endl << endl << endl;
cout << Product::getTotalSale() << endl << endl;
system("PAUSE");
return 0;
}
答案 0 :(得分:0)
我已经在 Visual Studio 2013 中完全构建了您的项目,没有更改文件,它确实有效!主函数的putput在以下
Cogniac
Ararat
10
200
100
300
Drinks
Water
20
1.25
0.0125
1.2625
Cigarret
Winston
5
100
100
500
301.25
你想要的结果吗? 我猜您的问题是编译器,您可以只清理项目并重建它。