If i run this code with just the object zip3 it runs fine but if i use any Zipcode objects before the string variable no longer works. It wont output even before being passed to the constructor Zipcode(string barcode). Very Confused appreciate any help. I believe the problem is cause because the string variable first is no longer working properly but not sure what is causing this.
Hint: You can edit your post, highlight your code and press the <> formatting button. This will not automatically indent your code. That part is up to you.
You can use the preview button at the bottom to see how it looks.
I found the second link to be the most help.
This is what I see when I tried to compile your code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
class Zipcode
{
public:
Zipcode(int x);
Zipcode(string barcode);
void output();
private:
void decode(string x);
int deco_helper(char x[]);
void read_check(char x[]);
string encode(); // <--- Declared, but not defined.
int zip[]; // <--- Needs a size.
};
Line 14 did produce a warning for me, but did compile. Without a size there is no elements in the array to work with.
I was just working on a practice project from my book based on the old US Mail POSTNET Format which displayed zipcodes in a barcode of 27 tall or short lines. So string barcode would represent 1 for tall lines and 0 for short in a 27 digit string. I then used decode() and deco_helper() to convert the barcode to a 5 digit zipcode. I hadnt gotten that far yet but i used encode() to convert the zipcode back to a barcode.