注册 登录
编程论坛 C++教室

帮忙解决error问题

晓宁 发布于 2011-09-15 01:41, 245 次点击
#include<iostream>
using namespace std;

class Average
{
private:
    int a,b,c,y;
    double i,j,k,z;
public:
    void multiplication(int d,int e,int f)
    {
        a = d;
        b = e;
        c = f;
    }

    void multiplication(double l,double m,double n)
    {
        i = l;
        j = m;
        k = n;
    }

    void showdata()
    {
        cout<<"\nAverage of integer :"<<y<<endl;
        cout<<"\nAverage of double :"<<z<<endl;
    }

    void calculate()
    {
        y = (a+b+c)/3;
        z = (i+j+k)/3;
    }
};

void main()
{
    int a,b,c,y;      
    double i,j,k,z;
    cout<<"Enter three integer number: "<<endl;
    cin>>a>>b>>c;
    cout<<"Enter three double number: "<<endl;
    cin>>i>>j>>k;
    Average avg;
    avg.multiplication(a,b,c);
    avg.multiplication(i,j,k);
    avg.calculate();
    avg.showdata();
}

看红字的error为什么会
aaa.cpp
C:\Users\CompaQ\Desktop\w\aaa.cpp(38) : warning C4101: 'y' : unreferenced local variable
C:\Users\CompaQ\Desktop\w\aaa.cpp(39) : warning C4101: 'z' : unreferenced local variable

1 回复
#2
tisyang2011-09-15 08:36
只是警告而已。。。。。
定义了变量,但是没有使用
1