Hello everyone, Okay with the help of some IRC people I figured out my code has circular dependancey, so i had to use forward headers.
I'm getting an error saying:
Code:1>EmailSubdomain.h(25) : error C2079: 'EmailSubdomain::Domains' uses undefined class 'EmailDomain' 1>EmailDomain.h(9) : fatal error C1083: Cannot open include file: 'EmailSubdomain': No such file or directory 1>EmailTld.cpp
Here is my EmailSubdomain.h
Code://file: EmailSubdomain.h //Code by: Cory Sanchez #pragma once #include "EmailDomain.h" #include <string> class EmailDomain; class EmailSubdomain { public: EmailSubdomain() { Name = ""; } public: EmailDomain Domains; std::string Name; public: bool IsValid(); };
And here is my EmailDomain.h
Code:/file: EmailDomain.h //Code by: Cory Sanchez #pragma once class EmailSubdomain; #include "EmailTld.h" #include "EmailSubdomain" #define MAX_SUBDOMAINS 10 #include <string> class EmailDomain { public: EmailDomain() { SubdomainCount = 0; Name = ""; } public: std::string Name; EmailTld Tld; EmailSubdomain Subdomain; int SubdomainCount; public: bool Parse(); bool IsValid(); int GetLengthSubdomain(const char *text, int startPos, char aChar); };
Any ideas what i'm not doing right?
Maybe i'm making this more complicated than it needs to be but what my main goal is this:
I have an Address passed into a Email object like this
Email email("[email protected]");
This will then get parsed in a member function of Email.h.
Email.h has 2 objects of another class EmailLocal.h and EmailDomain.h
I assign the Local Part of the address to EmailLocalPart.UserName =
I assign the Domain part of the addresss to EmailDomain.UserName =
Now There is also a TLD part of this e-mail:
[email protected]
"edu" is the TLD.
I parse out the TLD part from passing the EmailDomain.UserName to the class Domain.h which also has a Parse() function that will assign
EmailTld Tld.Name = tld;
But for me to do this I have to create make a data member in EmailDomain.h of type EmailTld, which is also a class. I don't see why this is illegal.
ANy help would be great.
Its also saying no such file as EmailTld.cpp but here's the code here right:
Also here is the heder for EmailTld.hCode://EmailTld.cpp #include "EmailTld.h" bool EamilTld::IsValid() const { if(Subdomain.IsVald() ) { return true; } else return false; }
Code://file: EmailTld.h //Code by: Cory Sanchez #pragma once #include "EmailSubdomain.h" // Subdomain and Tld are identical, except for // slight differences in validation rules, so to avoid repetition derive EmailTld class from EmailSubdomain base class class EmailTld: public EmailSubdomain // EmailTld class is derived from { public: EmailTld(); EmailSubdomain Subdomain; public: virtual bool IsValid(); };




Reply With Quote