Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3485148
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T10:52:23+00:00 2026-05-18T10:52:23+00:00

I am having trouble getting the compiler to accept my below defined user data

  • 0

I am having trouble getting the compiler to accept my below defined user data type (Term) that accepts another user data type (Rational) as a parameter. Any suggestions on how to make this work would be great!

#ifndef _TERM_H
#define _TERM_H

#include "Rational.h"

using namespace std;

class Term {

public:

    //constructors
    Term( const Rational &a, const int &b)
    { 
        this->coefficient = a;
        this->exponent = b;
    }

    Term(){}

    ~Term () {}

    //print the Rational
    void print()const 
    {
        cout << coefficient << " x^"  << exponent << endl;
    }

private:

    Rational *coefficient, *a;
    int exponent, b;
};

#endif

#ifndef _TERM_H
#define _TERM_H

using namespace std;

class Rational {

public:

    //constructors
    Rational( const int &a, const int &b){
        if (a != 0)
            if (b != 0)
                this->numerator = a;
            this->denominator = b;
    }

    //print the Rational
    void print()const {
        cout << numerator << "/" << denominator << endl;
    } 

    //add 2 Rationals 
    void add(const Rational &a, const Rational &b){
        numerator = ((a.numerator * b.denominator)+(b.numerator*a.denominator));
        denominator = (a.denominator*b.denominator);  
    }

 ...

    private:
     int a, b, numerator, denominator;
};

#endif

I keep getting the below error messages.

Term.h(30) : error C2440: ‘=’ : cannot convert from ‘const Rational’ to ‘Rational *’
1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T10:52:23+00:00Added an answer on May 18, 2026 at 10:52 am

    First, change the definition of coefficient to this:

    const Rational& coefficient;
    

    Then change the constructor to this:

    Term (const Rational& a, const int& b)
      : coefficient (a), exponent (b)
    {
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Getting started with jquery and having trouble getting hello world type example going for
I'm having trouble getting a rails app on Dreamhost's Passenger to see compiled libraries
I'm having trouble getting a rotary encoder to work properly with AVR micro controllers.
I've been having trouble getting my ASP.NET application to automatically log users into the
I'm having trouble getting the following to work in SQL Server 2k, but it
I'm having trouble getting the right number of elements in the ArrayList alt in
I am having trouble getting my ASP.NET application to start an application. For example
I'm having trouble getting in touch with SQL Server Managemen Studio 2008! I want
I am using HTML Purifier in my PHP project and am having trouble getting
I'm having some trouble getting log4net to work from ASP.NET 3.5. This is the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.