Thread: Private Static class members

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    May 2005
    Location
    Toronto, Canada
    Posts
    257

    Private Static class members

    Hi,

    I'm trying to write a class to hold two variables to be used by a number of functions in the program. Here's the class:
    Code:
    class InBAF
    {
    private:
    	static char location;
    	static CString server;
    
    public:
    	static void SetLocation(char newloc)
    	{
    		location = newloc;
    	}
    
    	static void SetServerName(char location)
    	{
    		switch (location)
    		{
    		case 'T':	
    				// Input Toronto Server
    			server = "ftp.pureftpd.org";
    			break;
    
    		case 'M':
    				// Input Montreal Server
    	                	server = "ftp.pureftpd.org"; 
    			break;
    		}
    	}
    
    	static CString GetServerName()
    	{
    		return server;
    	}
    };
    char InBAF::location = 'N';
    CString InBAF::server = '\0';
    when I try to compile I get this error for each member of the class:
    Code:
    private: static char  InBAF::location" (?location@InBAF@@0DA)
     already defined in GetData.obj
    GetData is a different function in my project; it has nothing to do with this class.

    What am I missing?

    and I tried:
    Code:
    CString InBAF::server[0] = '\0';
    but this comes up:
    Code:
    error C2466: cannot allocate an array of constant size 0
     error C2040: 'private: static class CString  InBAF::server' : 'class CString []' differs in levels of indirection from 'class CString'
    Last edited by earth_angel; 08-26-2005 at 09:48 AM. Reason: Code formating
    Everything is relative...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Message class ** Need help befor 12am tonight**
    By TransformedBG in forum C++ Programming
    Replies: 1
    Last Post: 11-29-2006, 11:03 PM
  2. Read-only class members
    By kidburla in forum C++ Programming
    Replies: 4
    Last Post: 10-14-2006, 12:52 PM
  3. are static class members the right choice?
    By drrngrvy in forum C++ Programming
    Replies: 6
    Last Post: 10-12-2005, 09:41 AM
  4. Need help with calculator program
    By Kate in forum C# Programming
    Replies: 1
    Last Post: 01-16-2004, 10:48 AM
  5. program to unpack packed data
    By vsk in forum C Programming
    Replies: 5
    Last Post: 11-14-2002, 09:17 PM