| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 826 人关注过本帖
标题:[求助]error C2065: 'total' : undeclared identifier
只看楼主 加入收藏
碍克
Rank: 1
等 级:新手上路
帖 子:48
专家分:0
注 册:2006-4-17
收藏
 问题点数:0 回复次数:2 
[求助]error C2065: 'total' : undeclared identifier
//一个描述商品销售的例子
#include "iostream.h"
class sale
{private:
float price;
char number;
char saleornot;
public:
void get(float p,int n,char s);
float total();
int sore();
};
//用关键字inline实现一个内联标记的作用
//inline就是告诉编译器内联编译的开始
inline void sale::get(float p,int n,char s)
{price=p;
number=n;
saleornot=s;
}
inline float sale::total()
{float t;
t=price*number;
return t;
}
inline int sale::sore()
{if(saleornot=='y')
return 1;
else return 0;
}
void main()
{sale goods1,goods2;
goods1.get(28.5,200,'y');
goods2.get(30,300,'n');
if(goods1.sore()==1)
{cout<<"the total sale amount of goods1 is :"<<"$"<<total()<<endl;}
else cout<<"the goods1 have not been sold!";
cout<<"\n";
if(goods2.sore()==1)
{cout<<"the total sale amount of goods2 is:"<<total()<<endl;}
else cout<<"the goods2 have not been sold!";}
搜索更多相关主题的帖子: identifier float undeclared sale 
2006-05-28 15:57
freshman42
Rank: 1
等 级:新手上路
威 望:1
帖 子:94
专家分:0
注 册:2005-12-4
收藏
得分:0 
以下是引用碍克在2006-5-28 15:57:00的发言:
//一个描述商品销售的例子
#include "iostream.h"
class sale
{private:
float price;
int number; //这里是整型吧
char saleornot;
public:
void get(float p,int n,char s);
float total();
int sore();
};
//用关键字inline实现一个内联标记的作用
//inline就是告诉编译器内联编译的开始
inline void sale::get(float p,int n,char s)
{price=p;
number=n;
saleornot=s;
}
inline float sale::total()
{float t;
t=price*number;
return t;
}
inline int sale::sore()
{if(saleornot=='y')
return 1;
else return 0;
}
void main()
{sale goods1,goods2;
goods1.get(28.5,200,'y');
goods2.get(30,300,'n');
if(goods1.sore()==1)
{cout<<"the total sale amount of goods1 is :"<<"$"<<goods1.total()<<endl;}
else cout<<"the goods1 have not been sold!";
cout<<"\n";
if(goods2.sore()==1)
{cout<<"the total sale amount of goods2 is:"<<goods2.total()<<endl;}
else cout<<"the goods2 have not been sold!";}


2006-05-28 16:04
碍克
Rank: 1
等 级:新手上路
帖 子:48
专家分:0
注 册:2006-4-17
收藏
得分:0 
[讨论]粗心

是我搞错了
谢谢啊

2006-05-28 16:40
快速回复:[求助]error C2065: 'total' : undeclared identifier
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.011405 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved