我的总是编译失败不能安装咋回事
1个回答
展开全部
stdafx.h加上,或者工程里设置成不适用预编译头。
需要包含的文件应该已经包含了,程序文件如下:
//cppe0731.cpp
#include "stdafx.h"
#include "sales_item.h"
int _tmain(int argc, _TCHAR* argv[])
{
Sales_item si("abc",1,99.00);
si.read();
si.write("hello",2,33.00);
si.read();
return 0;
}
//Sales_item.h
#include "stdafx.h"
class Sales_item
{
public:
Sales_item();
Sales_item(string,unsigned int,double);
void read()const;
void write(string,unsigned int,double);
private:
string isbn;
unsigned int count;
double prize;
};
// stdafx.h
#pragma once
#include <iostream>
#include <tchar.h>
#include <string>
using namespace std;
//sales_item.cpp
#include "sales_item.h"
Sales_item::Sales_item()
{
isbn="";
count=0;
prize=0;
}
Sales_item::Sales_item(string is,unsigned int cnt,double pri)
{
isbn=is;
count=cnt;
prize=pri;
}
void Sales_item::read()const
{
cout<<isbn<<'\t'<<count<<'\t'<<prize<<endl;
}
void Sales_item::write(string is,unsigned int cnt,double pri)
{
isbn=is;
count=cnt;
prize=pri;
}
需要包含的文件应该已经包含了,程序文件如下:
//cppe0731.cpp
#include "stdafx.h"
#include "sales_item.h"
int _tmain(int argc, _TCHAR* argv[])
{
Sales_item si("abc",1,99.00);
si.read();
si.write("hello",2,33.00);
si.read();
return 0;
}
//Sales_item.h
#include "stdafx.h"
class Sales_item
{
public:
Sales_item();
Sales_item(string,unsigned int,double);
void read()const;
void write(string,unsigned int,double);
private:
string isbn;
unsigned int count;
double prize;
};
// stdafx.h
#pragma once
#include <iostream>
#include <tchar.h>
#include <string>
using namespace std;
//sales_item.cpp
#include "sales_item.h"
Sales_item::Sales_item()
{
isbn="";
count=0;
prize=0;
}
Sales_item::Sales_item(string is,unsigned int cnt,double pri)
{
isbn=is;
count=cnt;
prize=pri;
}
void Sales_item::read()const
{
cout<<isbn<<'\t'<<count<<'\t'<<prize<<endl;
}
void Sales_item::write(string is,unsigned int cnt,double pri)
{
isbn=is;
count=cnt;
prize=pri;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询