Archive for May, 2009

Update Option

It’s written, I’m in the process of testing it. When I add a record to the file, I can find it again from options 3, 4, and 5, but not 6. I don’t understand why search would work for the first three but not the latter. Even when I search for records from the police data files, I get a display like this:

Name:     SSN: 1 –

Street:   City:

County: (00) OUT OF STATE   Zip Code: -   State: (00) **

Vehicle Make: (00) ***********    Vehicle Type: (0) ***********

Top Color: (00) *********      Bottom Color: (00) *********

Tag:

PersonToString()

Options 1-3 are tested and sound. Working on option 4, but my PersonToString() seems to be Abort coredumping. No idea why, it’s only calling the gets from Person. Well, it calls getSSN() just fine, but for everything after, it Abort coredumps. Also, I’ve checked the gets themselves, and they’re fine. Any ideas about what is going on?

Search

My search always says that it doesn’t find the record, even though I’m pulling SSNs straight from police 1 & 2. On Drew’s advice, I printed out all the SSNs that the input SSN is being compared to. After I tweaked a few things, it started finding the record – but it still said it didn’t. I found by using std::cerr that the program is going into the if (first > last) block that’s there as an initial precaution. No matter what I try, I can’t stop it from ending up in the (first > last) block. Here’s a snippet of the code:

for (first = 1; first < (numRecs – 1); first++) {
if (first > last) {
std::cerr << “inside if (first > last)\n”;
std::cerr << “Social Security Number ” << searchSSN.Hyphens() <<
” not found.\n”;
return 0;
}
middle = (first + last) / 2;

Error

Undefined                       first referenced
symbol                             in file
display(AuxDataMember const&, int)  opt2.o
displayRecord(Person const&)        opt3.o
ld: fatal: Symbol referencing errors. No output written to cbhproj
collect2: ld returned 1 exit status
make: *** [cbhproj] Error 1

Yet another error.

More Errors

Fixed the old errors, now I’m getting non-aggregate type errors. When I looked online to try to figure it out, everything I found said that these errors usually happen when you put parentheses after declaring a data member, which whouldn’t have them since it’s not a function. But the errors are for my DeleteRecord and Sort functions.

No Person skills

My SSN, Zip, and Car classes work. MasterData is nearing completion. I’ve written options 1, 2, 3, 5, and part of 4. I tried using the makefile for the first time today and it has a lot of problems with my Person class. In short, it’s not recognizing the names of the input strings that I declare in my prototypes, and it really hates my operator= overload. The errors for the operator= overload look like this:

Person.cpp:30: error: `const Person& operator=(const Person&)’ must be a
nonstatic member function
Person.cpp:30: error: `const Person& operator=(const Person&)’ must take
exactly two arguments
Person.cpp: In function `const Person& operator=(const Person&)’:
Person.cpp:31: error: invalid use of `this’ in non-member function
Person.cpp:31: error: invalid use of `this’ in non-member function
Person.cpp:32: error: `socsecnum’ undeclared (first use this function)
Person.cpp:33: error: `zip’ undeclared (first use this function)

etc., etc. I can’t figure it out.

EDIT: Tom caught this error without even looking at my code. I forgot to add the Person:: in front of operator=.

Question

My SSN class compiles just fine. I wrote a short test program, which also compiled just fine. But when I try to create an SSN object, I get a segfault core dump error. (I’ve tried with both constructors.) I can’t figure out where my error is hiding. My code looks like this:

SSN::SSN (const char * const input) {
set(dehyphenate());
}

Help?