我想我已經在這個程序中正確編碼了一切,但仍然出現錯誤。 對象si
它說它不可訪問。爲什麼在C++程序中出錯?
#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();
}
標題和解釋不是很好。請下次至少在標題中說明您的問題。 –