Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hi, So below are 3 files I have for a multifile project and i keep getting an error of: Undefined symbols for architecture x86_64: _main,

Hi, So below are 3 files I have for a multifile project and i keep getting an error of: Undefined symbols for architecture x86_64: "_main", referenced from: implicit entry/start for main executable ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) (1)fraction.h #include using namespace std; class fraction{ int num,deno; public: fraction(); fraction(int ,int ); fraction AddedTo(fraction); fraction Subtract(fraction); fraction MultipliedBy(const fraction); fraction DividedBy(const fraction); bool isGreaterThan(fraction); bool isEqualTo(fraction); void print(); }; (2)fraction.cpp #include"fraction.h" fraction::fraction(){ num=0; deno=1; } fraction::fraction(int n,int d ){ num=n; deno=d; } fraction fraction:: AddedTo(fraction f){ fraction val; val.num=this->num*f.deno+f.num*this->deno; val.deno=this->deno*f.deno; return val; } fraction fraction::Subtract(fraction f){ fraction val; val.num=this->num*f.deno-f.num*this->deno; val.deno=this->deno*f.deno; return val; } fraction fraction::MultipliedBy(const fraction f){ fraction val; val.num=this->num*f.num; val.deno=this->deno*f.deno; return val; } fraction fraction::DividedBy(const fraction f){ fraction val; val.num=this->num*f.deno; val.deno=this->deno*f.num; return val; } bool fraction::isGreaterThan(fraction f){ if(this->num*f.deno>this->deno*f.num)return true; return false; } bool fraction::isEqualTo(fraction f){ if(this->num*f.deno==this->deno*f.num)return true; return false; } void fraction::print(){ int a=this->num,b=this->deno,common_factor; while (1){ if(a==0||b==0){ common_factor=0; break; } if (a == b){ common_factor=a; break; } if (a > b)a-=b; else b-=a; } if(common_factor!=0){ cout<num/common_factor<<"/"<deno/common_factor<<" "; } else cout<num<<"/"<deno<<" "; }

(3) client.cpp

/*Client.cpp is set-up as a fraction class implementation and test driver program - DO NOT CHANGE SOURCE CODE

All necessary class objects are declared and defined here to test various class related operations.

HINT: see comments for specific class related function calls*/

#include

#include "fraction.h"

using namespace std;

int main()

{

fraction f1(9,8); //calling a parameterized class constructor

fraction f2(2,3);

fraction result; //calling a default class constructor

const fraction f3(12, 8);

const fraction f4(202, 303);

fraction f5,f6;

cout<<"C++ CLASS MULTI-FILE PROJECT"<

cout<<"Client.cpp - testing a fraction class implementation ";

cout<<"---------------------------------------------------- ";

cout << "The result object starts off at ";

result.showFraction(); //calling a void "observer" function

cout << endl;

cout<<" Arithmetic operations with fraction objects stored in the results class object ";

cout<<"------------------------------------------------------------------------------ ";

cout << "The sum of ";

f1.showFraction();

cout << " and ";

f2.showFraction();

cout << " is ";

result = f1.AddedTo(f2); //a class binary operation - a value-returning "observer" function

result.showFraction();

cout << endl;

cout << "The difference of ";

f1.showFraction();

cout << " and ";

f2.showFraction();

cout << " is ";

result = f1.Subtract(f2); //a class binary operation - a value-returning "observer" function

result.showFraction();

cout << endl;

cout << "The product of ";

f1.showFraction();

cout << " and ";

f2.showFraction();

cout << " is ";

result = f1.MultipliedBy(f2); //a class binary operation - a value-returning "observer" function

result.showFraction();

cout << endl;

result = f3.DividedBy(f4); //a class binary operation - a value-returning "observer" function

cout << "The quotient of ";

f3.showFraction();

cout << " and ";

f4.showFraction();

cout << " is ";

result.showFraction();

cout << endl;

cout<<" Input and Output operations for two new class objects ";

cout<<"----------------------------------------------------- ";

f5.getFraction(); //a class input operation - a transformer or setter function

f5.showFraction(); //a class output operation - an observer or getter function

cout<

f6.getFraction();

f6.showFraction();

cout<

cout<<" A Boolean operation comparing two class objects ";

cout<<"------------------------------------ ";

if (f5.isGreaterThan(f6)){ //a class relational expression - boolean operation/function

f5.showFraction();

cout <<" is greater than ";

f6.showFraction();

cout<

} else {

f5.showFraction();

cout <<" is less than ";

f6.showFraction();

cout<

}

cout<<" --------------------------------------------------------- ";

cout<<" Fraction class implementation test now successfully concluded ";

// system ("PAUSE");

return 0;

}

How do I fix this error?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Students also viewed these Databases questions

Question

1. Who should participate and how will participants be recruited?

Answered: 1 week ago

Question

3. How would this philosophy fit in your organization?

Answered: 1 week ago