|
-
Feb 16th, 2007, 12:24 PM
#1
Thread Starter
Hyperactive Member
Its saying Class isn't defined any ideas why?
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:
Code:
//EmailTld.cpp
#include "EmailTld.h"
bool EamilTld::IsValid() const
{
if(Subdomain.IsVald() )
{
return true;
}
else
return false;
}
Also here is the heder for EmailTld.h
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();
};
Last edited by voidflux; Feb 16th, 2007 at 12:33 PM.
C¤ry Sanchez
Computer Science/Engineering
@ Penn State
IBM.zSeries Intern
Mandriva 2007
-
Feb 16th, 2007, 04:39 PM
#2
Re: Its saying Class isn't defined any ideas why?
You have no file called "EmailSubdomain", yet you're trying to include it. Also, your classes have a recursive inclusion dependency, which is not possible.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Feb 16th, 2007, 05:16 PM
#3
Thread Starter
Hyperactive Member
Re: Its saying Class isn't defined any ideas why?
Thanks CornedBee my design was really screwed up!
Do I have any recrusive inclusion now?
For some reason i'm still getting an odd error though that says:
Code:
\EmailDomain.h(27) : error C2146: syntax error : missing ';' before identifier 'Tld'
1>EmailDomain.h(27) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
I fixed that problem by commenting out the EmailTld.cpp file, but now I'm back to my orginal error yay! but this one i think can be fixed easily but i'm not sure where
[code]
Hm....I seemed to resolved the problem by commenting out the EmailTld.cpp file, but now i'm getting the following:
Code:
EmailTld.h(13) : error C2504: 'EmailSubdomain' : base class undefined
1>EmailDomain.cpp
Code:
//file: Email.h
//Code by: Cory Sanchez
#pragma once
#include "EmailDomain.h"
#include "EmailLocalPart.h"
#include <string>
class Email
{
public:
Email(std::string address)
{
// Here we initialize Email’s internal
// Address property of type String
Address = address;
}
std::string Address;
EmailLocalPart LocalPart;
EmailDomain Domain;
void Parse();
bool IsValid();
};
Code:
//file: EmailDomain.h
//Code by: Cory Sanchez
#pragma once
//class EmailSubdomain;
#include "EmailTld.h"
#define MAX_SUBDOMAINS 10
#include <string>
class EmailDomain
{
public:
EmailDomain()
{
SubdomainCount = 0;
Name = "";
}
public:
std::string Name;
EmailTld Tld;
int SubdomainCount;
public:
bool Parse();
bool IsValid();
int GetLengthSubdomain(const char *text, int startPos, char aChar);
};
Code:
//file: EmailLocalPart.h
//Code by: Cory Sanchez
#pragma once
#include <iostream>
#include <string>
class EmailLocalPart
{
public:
EmailLocalPart()
{
UserName = "";
}
public:
std::string UserName;
public:
bool IsValid();
};
Code:
//file: EmailSubdomain.h
//Code by: Cory Sanchez
#pragma once
#include "EmailDomain.h"
#include <string>
//class EmailDomain;
class EmailSubdomain
{
public:
EmailSubdomain()
{
Name = "";
}
public:
std::string Name;
public:
bool IsValid();
};
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();
public:
virtual bool IsValid();
};
Last edited by voidflux; Feb 16th, 2007 at 05:36 PM.
C¤ry Sanchez
Computer Science/Engineering
@ Penn State
IBM.zSeries Intern
Mandriva 2007
-
Feb 16th, 2007, 05:41 PM
#4
Re: Its saying Class isn't defined any ideas why?
I don't see a cause for this error now.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Feb 16th, 2007, 05:50 PM
#5
Thread Starter
Hyperactive Member
Re: Its saying Class isn't defined any ideas why?
I got it working!!!!
It was quite strange, I had a few typos, and also I forgot to include somthing in the base class, thanks for the help though it made me realize how messed up my mind set was at the time!
C¤ry Sanchez
Computer Science/Engineering
@ Penn State
IBM.zSeries Intern
Mandriva 2007
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|