No matching function for call

Hello :)
I'm getting this error No matching function for call to 'input' here's my code:

Header.h
1
2
3
4
5
6
7
8
9
10
11
12
13
#include <iostream>
void input(int &a, const char * error = ""); //Some functions and classes

class SQUARE
{
private:
    double side;
    double area;
    double diagonal;
    double perimeter;
public:
    void populate();
};


Functions.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <iostream>
#include "Header.h"

void input(int &a, const char * error)       //Check for correct input
{
    using namespace std;
    
    while (!(cin >> a))
    {
        cin.clear();
        while (cin.get() != '\n') continue;
        cout << "Invalid Value! " << error << endl;
    }
}

void SQUARE::populate()                            //Populate class
{
    using namespace std;
    cout << "Enter the side of the square: ";
    input(side, "Please enter an integer: ");      //The error shows up here.
}


//Silly question

Thanks in advance :P
Last edited on
closed account (DSLq5Di1)
Look at the parameters of input(), now have a look at the parameters you are passing to it.
You may have other problems, but here's one hint:

void input(int &a, const char * error)

1
2
3
4
class SQUARE
{
private:
    double side;


input(side, "Please enter an integer: ");

edit: ah, beaten!
Last edited on
What a silly mistake >.> Thanks sloppy9 and ReedTompkins

Solved
1
2
3
4
5
6
7
8
9
10
11
12
template <class any>
void input(any &a, const char * error)
{
    using namespace std;
    
    while (!(cin >> a))
    {
        cin.clear();
        while (cin.get() != '\n') continue;
        cout << "Invalid Value! " << error << endl;
    }
}
Last edited on
is it head or header if its header then there is part of the problem also the arguements arent defined in the header
Topic archived. No new replies allowed.