분수 계산의 목표를 달성하기 위해 구조체를 올바르게 사용하는 방법을 알지 못합니다 (필수 사항 임). 솔직히 솔직히 내가하고있는 일에 대한 생각이별로 없어요. 이것은 C++의 제 3 클래스입니다. 잃어버린 느낌 ...이게 바로 과제입니다.struct를 이해하는 데 도움이 필요하고 프로그램에서 몇 가지 오류가 발생합니다.
Enter() 함수는 사용자로부터 소수를 받아들입니다. simplify() 함수는 이 가능한 경우받는 부분을 단순화합니다. display() 함수는 이받는 분수를 표시합니다.
전역 함수는 분수 형식을 사용합니다. 분수 유형은 분수의 분자와 분모를 별도의 데이터 멤버로 보유합니다.
이
내 프로그램은 " CIN"EXCEPT 만 메인 및 " COUT "이고 GCF 기능 해봤 주요 외부에서 교수에 의해 모든 다른 기능과 구조체를 구비 한 ...#include <iostream>
using namespace std;
void entry (int a, int b);
void simplify (double c);
void display(int x, int y)
int main()
{
struct Fraction fraction;
cout << "Enter a numerator: " << endl;
cin >> fraction.num;
cout << "Enter a denominator: " << endl;
cin >> fraction.den;
cout << "Fraction Simplifier" << endl;
cout << "===================" << endl;
enter(&fraction);
simplify(&fraction);
display(fraction);
}
struct Fraction {
int num;
int den;
}
struct Fraction fraction{
fraction.num;
fraction.den;
}
void display(int num, int den) {
cout << fraction.num << endl;
cout << fraction.den << endl;
}
// Great Common Factor (Euclid's Algorithm), provided by Professor
int gcf(int num1, int num2)
{
int remainder = num2 % num1;
if (remainder != 0)
{
return gcf(remainder,num1);
}
return num1;
}
을 자신을 위해이 내 오류는 다음과 같습니다
w2.cpp: In function 'int main()':
w2.cpp: 14: error: aggregate 'Fraction fraction' has incomplete type and cannot be defined
w2.cpp: 23: error: 'enter' was not declared in this scope
w2.cpp: At global scope: w2.cpp:35: error: function definition does not declare parameters
w2.cpp: In function 'void display(int, int)':
w2.cpp: 41: error: 'fraction' was not declared in this scope
정말 긴 게시물에 대해 유감이지만 모든 도움이 크게 감사드립니다. 누군가 집에서나 강의 중 (언어 장벽으로 인해 내 교수를 충분히 이해할 수 없음)도 읽을 수있는 유용한 C++ 서적을 알려줄 수 있다면
[The Definitive C++ Book Guide and List] (0120-555-9800) – ildjarn
달콤한, 도서 목록을 가져 주셔서 감사합니다! – Umeed
C++에서는 다른 함수를 사용하는 함수보다 먼저 사용해야합니다. main 앞에 다른 함수를 입력하십시오. 또한 앞으로 선언문을 사용할 수도 있지만이 시점에서 함수가 호출되는 함수보다 먼저 작성하는 것이 좋습니다. 또한 누락되었습니다. 라인 6에 – Topo