problem with classes

I am having trouble with calling a function from my class in main. Any help would be greatly appreciated.

Here's my header file:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#ifndef BINNUM_H
#define BINNUM_H

using namespace std;

class binNum
{
	private:
	char num [5];
	int num1;
	int num2;

	public:
	binNum();    //Default constructor
	void numbers();


};



#endif 


Here's my class file:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include "binNum.h"		//obtain prototype definitions
#include <iostream>

using namespace std;

binNum::binNum()
{
	num1 = 0;
	num2 = 0;
}

void binNum::numbers(void)
{
	cout << "Enter a 4 bit binary number entering only 0's and 1's: ";
	cin  >> num1;
	cout << "Enter another 4 bit binary number entering only 0's and 1's: ";
	cin  >> num2;
}


Heres my code for main:

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
#include "binNum.h"
#include "misc_ops.h"

#include <iostream>
#include <string>
#include <string.h>
using namespace std;

int main()
{

	binNum num;



	cout << "Binary number 1: " << num.numbers  << endl;
	cout << "Binary number 2: " << endl;


	  	//keeps the output window open
	cout << "Press enter to continue \n"; 
	cin.ignore();
	char ch = getchar();

  return 0;
}
To call the function you write num.numbers();. The return type is void it doesn't make sense trying to print the return value.
Topic archived. No new replies allowed.