숫자의 숫자 합계를 찾는 프로그램입니다. I은 'Z'는 Z의 원래 값이 소거되지 않으면 초기화초기화되지 않은 변수 읽기 오류
runtime failure:variable 'z' is being used without being initialized.
:
컴파일 된 코드는 오류를 범?
여기에 코드
#include<iostream>
#include<cmath>
#include<string>
#include<iomanip>
using namespace std;
class sumd
{
int x;
public:
void getdata()
{
int z=0;
cout<<"enter the no";
cin>>x;
z=x;
};
void sumdigit()
{
int z,y,sume,temp; // this is the line with the error...
for(temp=z;temp>0;temp/=10)
{
y=temp%10;
sume+=y;
}
cout<<sume;
};
};
int main()
{
sumd s1;
s1.getdata();
s1.sumdigit();
return 0;
}
코드를 제시 할 때 탭을 사용하지 마십시오. 좋은 레이아웃을 얻지 못합니다. 탭을 적절한 수의 공란으로 바꾸고 (적어도 유닉스에서는 그렇게 할 수있는 도구가있다.) 결과를 붙여 넣는다. –