error collect2: ld returned 1 exit status

When I run the following command I get an error as displayed below:

1
2
3
4
~/Desktop/Cs315/binary$ g++ -g test.cc binary.cc
/tmp/cctzzWZ5.o: In function `main':
/home/david/Desktop/Cs315/binary/test.cc:19: undefined reference to `binary::add(std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
collect2: ld returned 1 exit status


I can not figure out what I have done wrong here, The code is as follows:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
//test.cc

#include<iostream>
#include<vector>
using namespace std;
#include "binary.h"

int main(){
	vector<int> A;
	vector<int> B;
	vector<int> answer;
	A.push_back(0);
	A.push_back(1);
	A.push_back(0);
	A.push_back(1);
	A.push_back(1);
	B.push_back(1);
	B.push_back(0);
	B.push_back(1);
	binary bin;
	answer=bin.add(A,B);
	cout<<"THe answer has been calculated"<<endl;
	return 0;
	}


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//binary.h

#ifndef _binary_H_
#define _binary_H_

#include <iostream>
#include <vector>
using namespace std;

class binary{
	public:
	int bintodec(vector<int> bin);
	vector<int> dectobin(int dec);
	vector<int> add(vector<int> A,vector<int> B);
	vector<int> convertIntToVector(int);
	};
#endif



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
//binary.cc
//I can include more of the code if it is deemed necessary.

#include<iostream>
#include<cmath>
#include<vector>
using namespace std;
#include "binary.h"

vector<int> binary::dectobin(int dec){
	//...
}

int binary::bintodec(vector<int> bin){
	//...
}

vector<int> add(vector<int> A,vector<int> B){
//...	
  }

vector<int> convertIntToVector(int A){
//...	
	}


Thank you for any help that you can provide
try changing
vector<int> add(vector<int> A,vector<int> B)
into
vector<int> binary::add(vector<int> A,vector<int> B)
Thank you, I knew it had to be something simple that I was overlooking.
Topic archived. No new replies allowed.