小编use*_*947的帖子

为什么在c ++程序中出错?

我想我已经在这个程序中正确编码了一切但仍然出错.si它说的对象无法访问.

#include<conio.h>
#include<iostream.h>

class s_interest
{
    int p,t;
    float r;
    s_interest(int a, int b, float c)
    {
        p=a;
        r=b;
        t=c;
    }

    void method()
    {
        int result=(float)(p*t*r)/100;
        cout<<"Simple interest:"<<result;
    }
};

void main()
{
    int pr,ti;
    float ra;
    cout<<"\n Enter the principle, rate of interest and time to calculate Simple Interest:";
    cin>>pr>>ti>>ra;
    s_interest si(pr,ti,ra);
    si.method();
}
Run Code Online (Sandbox Code Playgroud)

c++ class object

3
推荐指数
1
解决办法
100
查看次数

标签 统计

c++ ×1

class ×1

object ×1