i keep getting these errors with my program and i was wondering if anyone can help.
/tmp/cc2Rxau2.o: In function `main':
prac.cpp:(.text+0x101): undefined reference to `Barcode::Barcode()'
collect2: ld returned 1 exit status
Code:
#include <iostream>
using namespace std;
class Barcode
{
public:
Barcode(int zipcode);
Barcode(char bar);
Barcode();
int convert(int num);
private:
int return_bar();
int return_zip();
};
int main()
{
int choice;
int usrzip;
Barcode zip;
cout << "enter 1 if you want to change a zipcode to barcode, or a 2 for a barcode to zipcode." << endl;
cin >> choice;
if(choice == 1)
{
cout << "enter your 5 digit zipcode." << endl;
cin >> usrzip;
int num1, num2, num3, num4, num5;
int temp1, temp2, temp3, temp4;
int bar_num1, bar_num2, bar_num3, bar_num4, bar_num5;
num1 = usrzip % 10;
temp1 = usrzip / 10;
num2 = temp1 % 10;
temp2 = temp1 / 10;
num3 = temp2 % 10;
temp3 = temp2 / 10;
num4 = temp3 % 10;
temp4 = temp3 / 10;
num5 = temp4 % 10;
cout << num5 << " " << num4 << " " << num3 << " " << num2 << " " << num1 << endl;
bar_num1 = zip.convert(num1);
bar_num2 = zip.convert(num2);
bar_num3 = zip.convert(num3);
bar_num4 = zip.convert(num4);
bar_num5 = zip.convert(num5);
cout << bar_num5 << bar_num4 << bar_num3 << bar_num2 << bar_num1 << endl;
}
}
int Barcode :: convert(int num)
{
char result;
switch(num)
{
case 1:
result = 00011;
break;
case 2:
result = 00101;
break;
case 3:
result = 00110;
break;
case 4:
result = 01001;
break;
case 5:
result = 01010;
break;
case 6:
result = 01010;
break;
case 7:
result = 10001;
break;
case 8:
result = 10010;
break;
case 9:
result = 10001;
break;
default:
cout << "not valid choice." << endl;
}
}