| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 557 人关注过本帖
标题:怎么侬都看不出那边有错,这个cpp文件到底怎么改?
取消只看楼主 加入收藏
gaojiannew
Rank: 1
等 级:新手上路
帖 子:6
专家分:6
注 册:2013-8-27
结帖率:0
收藏
已结贴  问题点数:10 回复次数:0 
怎么侬都看不出那边有错,这个cpp文件到底怎么改?
h文件是
#ifndef saving
#define saving
#include"account.h"
class Savings:public Account
{
public:
    Savings(unsigned accNo,float balan=0.0);
    virtual void Withdrawal(float amount);
protected:
    static float minbalance;
};
#endif
cpp文件是#include
#include<iostream.h>
#include"account.h"
#include"saving.h"
static Savings::minbalance=500.0;
Savings::Savings(unsigned accNo,float balan=0.0):Account(accNo,balan){}
virtual void Saving::Withdrawal(float amount)
{
    if(balance+minbalance<amount)
        cout<<"You have no enough money!";
    else
        balance-=amount;
}
编译的时候 错误是:
C:\Program Files\Microsoft Visual Studio\MyProjects\ch16_2\savings.cpp(4) : error C2720: 'minbalance' : 'static ' storage-class specifier illegal on members
Error executing cl.exe.
去掉cpp文件中static又有如下错误:
C:\Program Files\Microsoft Visual Studio\MyProjects\ch16_2\savings.cpp(4) : error C2501: 'minbalance' : missing storage-class or type specifiers
C:\Program Files\Microsoft Visual Studio\MyProjects\ch16_2\savings.cpp(4) : error C2371: 'protected: static float Savings::minbalance' : redefinition; different basic types
        c:\program files\microsoft visual studio\myprojects\ch16_2\savings.h(10) : see declaration of 'protected: static float Savings::minbalance'
Error executing cl.exe.


[ 本帖最后由 gaojiannew 于 2013-9-20 14:06 编辑 ]
搜索更多相关主题的帖子: saving amount public include 
2013-09-20 14:04
快速回复:怎么侬都看不出那边有错,这个cpp文件到底怎么改?
数据加载中...
 
   



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

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