Feb 23, 2021 at 3:29pm UTC
How do I fix this error in my .cpp file?
C:\Data structures-r\Polynomials Lab\src\Term.cpp|12|error: no declaration matches 'Term::Term(double, int)'|
include\Term.h|8|note: candidates are: 'constexpr Term::Term(const Term&)'|
C:\Data structures-r\Polynomials Lab\src\Term.cpp|6|note: 'Term::Term()'|
Thanks!
.h file
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
#include <string>
using namespace std;
#ifndef TERM_H
#define TERM_H
class Term
{
public :
Term();
Node(double coefficient, int power);
~Term();
double Getcoefficient() { return m_coefficient; }
void Setcoefficient(double val) { m_coefficient = val; }
int Getpower() { return m_power; }
void Setpower(int val) { m_power = val; }
void display();
protected :
private :
double m_coefficient;
int m_power;
};
#endif // TERM_H
.cpp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
#include "Term.h"
#include <iostream>
#include <string>
using namespace std;
Term::Term()
{
m_coefficient = 0;
m_power = 0;
}
Term::Term(double coefficient, int power)
{
m_coefficient = coefficient;
m_power = power;
}
Term::~Term()
{
//dtor
}
void Term::display()
{
cout << m_coefficient << " " << m_power << endl;
}
Last edited on Feb 23, 2021 at 3:31pm UTC
Feb 23, 2021 at 3:41pm UTC
Line 12: Change Node
-> Term
Feb 23, 2021 at 4:17pm UTC
Happens to everyone! A nice trick when you don't see a mistake is to literally read the code out loud to yourself ("rubber duck debugging", as if you're talking to a rubber duck that listens to your problems). It sounds silly but it can help.
Feb 23, 2021 at 5:02pm UTC
Taking a break can be a big help too.