Welcome! Log In Create A New Profile

Advanced

Meaning of error "new types may not be defined in return type"

Posted by S S J 
Announcements Last Post
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
Meaning of error "new types may not be defined in return type"
November 16, 2009 12:41PM
Urgent Help needed!


Hi there!

I am getting the following error on my compiler when i compile some programmes

"new types may not be created in return type".

These programmes are sometimes identical to the solution code provided in the tutorial letters.

I cannot trace this error.

A similr error that I cannot understand is :" extraneous int"

Please could someone help urgently.

I am using the dev IDE in vista. I am not sure whether that makes a difference.

thx.
avatar Re: Meaning of error "new types may not be defined in return type"
November 17, 2009 09:05AM
Do you have any examples that you've gotten these errors with? The MinGW compiler has been known many times to give vague error messages so it helps if there's a context.
Re: Meaning of error "new types may not be defined in return type"
November 17, 2009 04:30PM
Thanks
the example is the solution code provided for question2 of Assignment 2
Re: Meaning of error "new types may not be defined in return type"
November 17, 2009 04:50PM
the solution code provided for question2 of Assignment 2 will solve your problem
Re: Meaning of error "new types may not be defined in return type"
November 18, 2009 10:24AM
but its not solving the problem.

I reproduce it hereunder. there may be very slight variances from the actual solution code but this should not affect compilation.
I'll really appreciate an experienced coder's help.
Thanks

#include <iostream>
#include <cassert>
using namespace std;

class Fraction
{ public :
Fraction (int numerator, int denominator);
Fraction (int numer);
Fraction();

Fraction add (const Fraction& rhs) const;
Fraction sub (const Fraction& rhs) const;
Fraction mul (const Fraction& rhs) const;
Fraction div (const Fraction& rhs) const;

void output (ostream& outs) const;



private:
int n;
int d;
}

int main()
{

Fraction a(-5, -6), b(2), c(1, -3), d;
a.output(cout); cout<< endl;
b.output(cout); cout<< endl;
c.output(cout); cout << endl;



cout<< endl;
return 0;
}

Fraction::Fraction(int numerator, int denominator)
{
assert (denominator !=0);
n=numerator;
d=denominator;
}

Fraction::Fraction (int numer) : n(numer), d(1)
{
}

Fraction::Fraction(): n(0), d(1)
{
}

void Fractioneye popping smileyutput(ostream& outs) const
{
outs<< n << " / " << d;
}

Fraction Fraction::add(const Fraction& rhs) const
{
int numer, denom;
numer = (n * rhs.d) + (d*rhs.n);
denom = (d* rhs.d);
Fraction local;
local (numer, denom);
return local;
}

Fraction Fraction::sub(const Fraction& rhs)const
{
int numer = n*rhs.d - d*rhs.n;
int denom = d*rhs.d;
Fraction local (numer, denom);
return local;
}

Fraction Fraction::mul (const Fraction& rhs) const
{
int numer = n*rhs.n;
int denom = d*rhs.d;
Fraction local (numer, denom);
return local;
}

Fraction Fraction::div (const Fraction& rhs) const
{
int numer= n*rhs.d;
int denom= d*rhs.n;
Fraction local (numer, denom);
return local;
}
avatar Re: Meaning of error "new types may not be defined in return type"
November 18, 2009 11:01AM
Language: C++
Fraction Fraction::add(const Fraction& rhs) const { int numer, denom; numer = (n * rhs.d) + (d*rhs.n); denom = (d* rhs.d); Fraction local; local (numer, denom); ///// <<<<< INVALID return local; }

There's no function called 'local'. If you are trying to call the constructor, you must do this at the time of creation (ie the previous line).
Re: Meaning of error "new types may not be defined in return type"
November 19, 2009 11:56AM
Thanks alot . Really appreciate the help.
but its still giving the same error.

do you think i should try and use another IDE like ms visual c++?

and by the way there is also another error that says: "main must return int"
I wonder what that means.
Sorry, only registered users may post in this forum.

Click here to login