Thread: error C2248: '()' : cannot access private member declared in class ...

  1. #1
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545

    error C2248: '()' : cannot access private member declared in class ...

    I don't know what's wrong with me today, but it's taking way too long to get this little piece of code to compile properly:
    Code:
    #ifndef STRUTILS_H_INCLUDED_FEB_14_2008
    #define STRUTILS_H_INCLUDED_FEB_14_2008
    
    #include <string>
    #include <algorithm>
    #include <functional>
    #include <cctype>
    
    #ifdef UNICODE
    #	define TCHAR	wchar_t
    #else
    #	define TCHAR	char
    #endif
    
    
    namespace StrUtils
    {
    	template <typename T>
    	class CharLessNoCase	:	public std::binary_function<T, T, bool>
    	{
    		bool operator()( T  c1, T  c2 )
    		{
    			return (tolower( static_cast<unsigned T>(c1) ) <
    				tolower( static_cast<unsigned T>(c1) ));
    		}
    	};
    
    
    	template <typename T>
    	bool StringCompareNoCase(  std::basic_string<T>&  str1,
    				   std::basic_string<T>&  str2 )
    	{
    		return std::lexicographical_compare( str1.begin(), str1.end(),
    						     str2.begin(), str2.end(),
    						     CharLessNoCase<T>() );
    	}
    }
    
    #endif	// STRUTILS_H_INCLUDED_FEB_14_2008
    VC++ 6.0 is saying:
    c:\program files\microsoft visual studio 6.0\vc98\include\xutility(60) : error C2248: '()' : cannot access private member declared in class 'StrUtils::CharLessNoCase<unsigned short>'
    d:\vss_root\devel\include\base\strutils.h(24) : see declaration of '()'
    d:\vss_root\devel\include\base\strutils.h(38) : see reference to function template instantiation 'bool __cdecl std::lexicographical_compare(unsigned short *,unsigned short *,unsigned short *,unsigned short *,class StrUtils::CharLessNoCase<unsigned short>)' being compiled
    Even Comeau is choking on it, so it has to be something I'm doing wrong, but I just can't see what it is...

  2. #2
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    Perhaps it's because your operator() is private?

  3. #3
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Yeah, I just noticed that. Doh!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Private class member not being set
    By cboard_member in forum C++ Programming
    Replies: 4
    Last Post: 04-06-2007, 11:38 AM
  2. Replies: 28
    Last Post: 07-16-2006, 11:35 PM
  3. <Gulp>
    By kryptkat in forum Windows Programming
    Replies: 7
    Last Post: 01-14-2006, 01:03 PM
  4. Using private class members in static functions
    By sethjackson in forum C++ Programming
    Replies: 2
    Last Post: 09-23-2005, 09:54 AM
  5. Nested loop frustration
    By caroundw5h in forum C Programming
    Replies: 14
    Last Post: 03-15-2004, 09:45 PM