Okay, this error is rather annoying, as I can not progress with my program without resolving it.
It is an e-mail checker, and this part is extracting the domains (we previously did it with arrays) using a user-defined template vector class (using char as the type). As of now I'm completely stumped since most of the code was pseudo code from my professor, so I know I'm at least on the right track...
Code:
class EmailDomain
{
public:
EmailDomain()
{
Name = DynamicString::DynamicString();
SubdomainCount = 0;
}
public:
DynamicString Name;
Vector<char> Subdomain;
//EmailSubdomain Subdomain[MAX_SUBDOMAINS];
int SubdomainCount;
EmailTld Tld;
public:
bool Parse();
bool IsValid();
};
Code:
// Extract subdomains
do
{
int nextPosition = Name.IndexOf('.', startPosition);
Subdomain.BoostCapacity(1);
if ( nextPosition != -1 )
{
Name.Copy(Name.Buffer, Subdomain.Buffer, startPosition + 1, nextPosition - startPosition);
Subdomain.InsertAt( Subdomain.Size, Subdomain.Buffer );
}
else
Name.Copy(Name.Buffer, Tld.Name.Buffer, startPosition + 1, Name.Size);
startPosition = nextPosition + 1;
} while ( startPosition != 0 );
Buffer is of type T* (so in this case....char*) in the vector class
And here is the InsertAt function from the Vector class
Code:
void InsertAt(int index, const T& value)
{
if ( index > Size || index < 0 )
throw "Vector::InserAt() index out of range";
// Exceeding current capacity?
BoostCapacity(1);
// Make room for the new intacter
MoveBy(index, 1);
Size++;
// Set the value
Buffer[index] = value;
}
The error occurs on the line that is bold, italicized and underlined
If you need anything else, just ask me. Thanks!