Thread: Though implementation problem

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654

    Tough implementation problem

    OK, here's another tough implementation problem.
    CTmplStringBase will have one of two functions depending on what type T is, so naturally to this, a specialized template would be required.
    Unfortunately, that means I have to create a new class and inherit from, else I would have to remake the entire class in the specialization.
    But this new class returns an object of the class it inherits from, so it, in turn, needs the inheriting class to be defined first.
    But then, the code won't compile because CTmplStringBase would try to derive from an undefined class.
    So what's a solution to this?

    CTmplStringBase wants to derive from StrConversions:
    Code:
    	template<typename T, typename Traits> class CTmplStringBase:
    		public StrConversion<T>,
    Because it wants access to specialized template member functions:
    Code:
    	template<typename T> class StrConversion { };
    	template<> class StrConversion<char>
    	{
    	public:
    		CStringExW ToUTF16();
    	
    	private:
    		virtual const char* GetData() = 0;
    	};
    	
    	template<> class StrConversion<wchar_t>
    	{
    	public:
    		CStringExA ToANSI();
    	
    	private:
    		virtual const wchar_t* GetData() = 0;
    	};
    But StrConversion wants to return objects of CTmplStringBase, so I get circular dependencies.
    Last edited by Elysia; 05-11-2008 at 10:00 AM.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM
  2. Laptop Problem
    By Boomba in forum Tech Board
    Replies: 1
    Last Post: 03-07-2006, 06:24 PM
  3. implementation file
    By bejiz in forum C++ Programming
    Replies: 5
    Last Post: 11-28-2005, 01:59 AM
  4. Replies: 5
    Last Post: 11-07-2005, 11:34 PM
  5. Memory Problem - I think...
    By Unregistered in forum C Programming
    Replies: 4
    Last Post: 10-24-2001, 12:14 PM