I'm getting the error message "Error: expected initializer before 'sum' " from line 9 of my code when I try to compile my program. I can't seem to figure out why it would be throwing this error. Any help would be great. Thanks!

#include <iostream>
using namespace std;

struct Frac;
{
      int numerator;
      int denominator;
}
Frac sum(Frac& fract1, const Frac& fract2);
Frac Sub(Frac& fract1, const Frac& fract2);
Frac Mul(Frac& fract1, const Frac& fract2);
Frac Div(Frac& fract1, const Frac& fract2);

Recommended Answers

All 3 Replies

haha common error!!

You forgot the semicolon on line 8 after the }
Structs always have a semicolon after the last bracket

so add the semicolon on line 8

};

commented: Thanks duder +1

Oh and also
Line 4

struct Frac;

u shouldnt have a semicolon after the

Frac

Oh wow, don't I feel sheepish! :)
Thanks for the help!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.