请高手看看哪里出错了。

Jennypan2009 2010-09-20 10:46:32
程序如下
//SalesPerson clss definition
// Menber functions defined is salesp.cpp
#ifndef SALESP_H
#define SALESP_H

class SalesPerson{
public:
SalesPerson();
void GetSalesFromUser();
void SetSales ( int, double);

void printAnnualSales();

private:
double totalAnnualSales();
double sales [12];
};

#endif

//Fig 6.7 sales
//member functions for class SalesPerson
#include<iostream.h>
#include<iomanip.h>
#include"salesp.h"

//constructor functioninitializes array
SalesPerson::SalesPerson()
{
for( int i = 0; i < 12; i++)
sales[i] = 0.0;
}

//Function to get 12 sales figures from the user
//at the key board
void SalesPerson::GetSalesFromUser()
{
double salesFigure;
for (int i = 0; i<12; i++)
{
cout<< "Enter sales amount for month"
<< i + 1 <<":";
cin >> salesFigure;
setSales(i,salesFigure);
}
}

//function to set one of the 12 mothly sales figures.
// note that the month value must be from 0 to 11
void SalesPerson::SetSales( int month, double amount )
{
if ( month >= 0 && month < 12 && amount >0 )
sales[month] = amount;
else cout << "Invalid month or sales figure" << endl;
}

// print the total annual sales
void SalesPerson:: printAnnualSales()
{
cout << setprecision(2)
<< setiosflags (ios::fixed | ios::showpoint )
<< "\nThe total annual sales are:$"
<< totalAnnualSales() << endl;
}
//private utility function to total annual sales
double SalesPerson::totalannualSales()
{
double total = 0.0;

for ( int i = 0; i < 12; i++ )
total += sales[i];

return total;
}
//fig 6_7
//demonstrating a utility functon
//compile with salesp.cpp
#include "salesp.h"

int main()
{
SalesPerson s;

s.GetSalesFromUser();
s.printAnnualSales();

return 0;
}
编译后显示
fatal error C1083: Cannot open include file: 'salesp.h': No such file or directory
...全文
102 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
哇咔咔loveshh 2010-09-20
  • 打赏
  • 举报
回复
你干脆去找到你的那个头文件然后将它的绝对路径包含进来
Ionstorm2 2010-09-20
  • 打赏
  • 举报
回复
你看看这个头文件有没有包含在你的头文件库里。。。。。
如果有,看看这个头文件的属性是不是为只读,你有没有权限访问这个文件?
hai040 2010-09-20
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 jennypan2009 的回复:]
知道错误提示,但找不到错在哪里:下面是我查到引起这个错误的原因。
File does not exist.

File, subdirectory, or disk is read-only.

No access permission for file or directory.

Not enough file handles. Close some applications a……
[/Quote]
一般是第一个原因,文件不存在
而文件不存在通常是因为路径错误或拼写错误
某某9 2010-09-20
  • 打赏
  • 举报
回复
nclude这个文件了吗 'salesp.h'???????
是不是路径填错了!
小楫轻舟 2010-09-20
  • 打赏
  • 举报
回复

//Fig 6.7 sales
//member functions for class SalesPerson
#include<iostream> // ----------------------------现在一般都用using namespace std
#include<iomanip>
#include"salesp.h"
using namespace std;
//constructor functioninitializes array
SalesPerson::SalesPerson()
{
for( int i = 0; i < 12; i++)
sales[i] = 0.0;
}

//Function to get 12 sales figures from the user
//at the key board
void SalesPerson::GetSalesFromUser()
{
double salesFigure;
for (int i = 0; i<12; i++)
{
cout<< "Enter sales amount for month"
<< i + 1 <<":";
cin >> salesFigure;
SetSales(i,salesFigure); //--------------------------------- 不是setSales
}
}

//function to set one of the 12 mothly sales figures.
// note that the month value must be from 0 to 11
void SalesPerson::SetSales( int month, double amount )
{
if ( month >= 0 && month < 12 && amount >0 )
sales[month] = amount;
else cout << "Invalid month or sales figure" << endl;
}

// print the total annual sales
void SalesPerson:: printAnnualSales()
{
cout << setprecision(2)
<< setiosflags (ios::fixed | ios::showpoint )
<< "\nThe total annual sales are:$"
<< totalAnnualSales() << endl;
}
//private utility function to total annual sales
double SalesPerson::totalAnnualSales() // 不是---------------------totalannualSales
{
double total = 0.0;

for ( int i = 0; i < 12; i++ )
total += sales[i];

return total;
}
Jennypan2009 2010-09-20
  • 打赏
  • 举报
回复
知道错误提示,但找不到错在哪里:下面是我查到引起这个错误的原因。
File does not exist.

File, subdirectory, or disk is read-only.

No access permission for file or directory.

Not enough file handles. Close some applications and recompile

哪位高手能告诉我具体错在哪吗?
小楫轻舟 2010-09-20
  • 打赏
  • 举报
回复
你有salesp.h文件吗?
放的位置是不是正确?
Ionstorm2 2010-09-20
  • 打赏
  • 举报
回复
没有salesp.h这个头文件,看看头文件名有没有写错。。。
Domain4.3(明小子)10.10.10更新版主要更新内容如下: 1.驱除部分死连接,恢复部分官方连接 2.改变默认显示页面为本人BLOG 3.修正程序在检测时出错的BUG 4.修正程序在部分系统中无法启动的BUG 5.加了一个功能模块,但还不成熟,隐藏了,高手的话可以用OD调出来!>!< 6.修复前段时间一些朋友反映的错误和程序宏 7.增加四款SKN皮肤! 10.10.11紧急更新: 1.修正新版程序在部分系统中启动后直接导致系统蓝屏的BUG 2.修正域名查询的几个错误 3.修正程序批量检测查询到域名的时候无反映的BUG! Domain4.2(明小子)10.01.16更新版主要更新内容如下: 1.删除所有无关数据 2.优化急速代码 3.改变启动线程 4.增加SQL数据批量导出功能 5.加入几个优化进程模块,非后门.后台运行. 6.锁定主程序栏目宽和高,不在恢复 7.删除“辅助工具”模块中全部代码 8.修正XP SP3 程序下兼容问题 9.重新改写域名查询旁站线程 程序于2010年01月16号调试完毕! 提别提示:第4个功能只能运行在完整版的windows XP 平台系统中,其他平台无法运行,如果出现恢复按钮并不能保存自行调试与本程序无关.谢谢合作! 宝宝的话:有朋友们的鼓励才会有这个版本的发布,这当是我送给大家2010年里的第一个礼物吧。 Domain4.1(明小子)0901更新版主要更新内容如下: 1.增加新系统兼容模块,全面兼容2000-2008各系统 (部分精简版系统除外) 2.优化网站打开速度,删减部分无用内核信息,全面加快程序启动速度. 3.基于09.05.20号内核提升,改变搜查循环的一个死BUG! 4.删除在0520上增加的一个补针函数,并使用新的函数替换.保证不报错. 5.不在兼容xpsp3,因为没时间去修正这个错误。所以可能部分SP3系统运行不起来本程序 6.增加部分程序扩充空格代码,为下个版本更新做好铺垫 小提示:保留旧的IP反查连接系统,原因没有找到新的和稳定的IP反差服务器!如果有能提供的与本人联系!谢谢合作 Domain4.1(明小子)0520更新版主要更新内容如下: 1.基于08.10.01号内核提升,修正一次关键错误。 2.替换原程序自带的那个小马,该为最新美化免杀版的小马! 3.添加一个服务器挂钩程序(非插件),使修改后的新内核兼容vista系统。 4.程序数据库默认名为:SetData.mdb 大家使用3.5版本以上的MDB数据.其他低版本程序可能不兼容! 5.删除后台下载统计代码(以前没发现,本人也是从网站上面下的软件,排除作者自添加行为) 6.加了一个补针,针对sql注入功能中的一个小BUG。 7.删除了很多没有用的代码,最大限度的优化程序启动速度。 8.更新部分在xpsp3下出错的几个小BUG(小问题小解决,这个错误仅针对部分优化过度的XPSP3系统)。 提记:很多朋友说需要修改下程序IP域名查询功能,这里说明下.由于内核找不到关键句柄导致无法更新,下个版本在仔细看看! Domain4.0(明小子)1001更新版主要更新内容如下: 1.更新部分过度优化过的系统不兼容问题。 2.修改内存识别函数,使其降低软件在使用期间所占用的内存大小。 3.基于08.09.15号内核提升,修正因修改软件所出现的几个导致软件崩溃的几个BUG。 4.换了软件自带的那个垃圾皮肤。加入兼容美化皮肤!更美观! 5.兼容前版本数据库支持功能 6.去掉了没有用的PHP入侵选项和几处小BUG...... 转贴是一种美德!分享也是一种快乐,工具仅做辅助作用勿用在非法用途上! 程序自带本BLOG连接,启动比较慢!不喜勿用!谢谢合作!

33,311

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 新手乐园
社区管理员
  • 新手乐园社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧