Results 1 to 5 of 5

Thread: Its saying Class isn't defined any ideas why?

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member voidflux's Avatar
    Join Date
    Jun 2003
    Location
    Brockway, PA
    Posts
    290

    Arrow 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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width