calling functions from templates

Having issues calling my arguements from my templates, when i declare x and n in the main it comes up with errors

Anyone have a resultion to this issue?

code below:

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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include <iostream>
#include <cmath>
#include <cstring>
#include <string>
#include <string.h>

using namespace std;

int intInput1, intInput2;
float floatInput1, floatInput2;

template <class T>
class Number
{
public:
	Number<T>::Number()
	{
		int x = 0;
	}

	void Set(int *x)
	{
		value = x;
	}

	int Get()
	{
		return value;
	}
private:
	int value;

public:

void isEqual(T x, T n)
{	
	Set(0);
	*n = 6;

	if (x == n)
	{
		printf("is equal");
		cout << endl;
	}
	else 
	{
		isBigger(T x, T n);
		isSmaller(T x, T n);
	}
}

void isBigger(T *x, T *n)
{
	if (x > n)
	{
		cout << x << " is bigger than " << n << endl;
	}
}

void isSmaller(T *x, T *n)
{
	if (x < n)
	{
		cout << x << " is smaller than " << n << endl;
	}
}

};

int main()
{
	cout << "Worksheet 12 task 3" << endl;
	Number <int> i;
	i.isEqual();
	i.isBigger();
	i.isSmaller();

	cin.ignore(2);
}
There are no x no n in the main. So it is not clear what you are saying about.
As for expressions

1
2
3
	i.isEqual();
	i.isBigger();
	i.isSmaller();


then they are invalid because there are no such function declarations in class Number. The class member functions with the same names as above have parameters.

I gtry and declare x and n in the main yet im getting errors saying that they are undefined
I have understood nothing.
Sorry heres my edited code, i've commented the errors

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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#include <iostream>
#include <cmath>
#include <cstring>
#include <string>
#include <string.h>

using namespace std;

int intInput1, intInput2;
float floatInput1, floatInput2;

template <class T>
class Number
{
public:
	Number<T>::Number()
	{
		int x = 0;
	}

	void Set(int *x)
	{
		value = x;
	}

	int Get()
	{
		return value;
	}
private:
	int value;

public:

void isEqual(T x, T n)
{	
	Set(0);
	
	if (x == n)
	{
		printf("is equal");
		cout << endl;
	}
	else 
	{
		isBigger(T x, T n);
		isSmaller(T x, T n);
	}
}

void isBigger(T x, T n)
{
	if (x > n)
	{
		cout << x << " is bigger than " << n << endl;
	}
}

void isSmaller(T x, T n)
{
	if (x < n)
	{
		cout << x << " is smaller than " << n << endl;
	}
}

};

int main()
{
	cout << "Worksheet 12 task 3" << endl;
	Number<class T> num;

	cout << "Please enter 2 integers" << endl;
	cin >> intInput1;
	cin >> intInput2;
	num.isEqual(x, n); //Errors

	cout << "Please enter 2 floats" << endl;
	cin >> floatInput1;
	cin >> floatInput2;
	num.isEqual(x, n) // Errors;

	cin.ignore(2);
}
Topic archived. No new replies allowed.