Thread: Integer Emulation

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #5
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by iMalc View Post
    Bug here:
    Code:
    TT CThreadClassType<T>::CThreadClassType(CClassType& Data)
    {
    	InitializeCriticalSection(&m_Sync); // BUG!!!!
    	EnterCriticalSection(&m_Sync);
    	m_bLogging = Data.m_bLogging;
    	m_Data = Data.m_Data;
    	LeaveCriticalSection(&m_Sync);
    }
    Bug? How do you figure? It's a constructor, so it needs to initialize the critical section.

    Quote Originally Posted by iMalc View Post
    I would perfer the two parameter friend function version of operators like binary + so that both sides are implicitly convertable.
    You mean such as
    Code:
    operator + (T, const CDataType<T>& )
    I think?

    Quote Originally Posted by iMalc View Post
    Spelling mistake: MinEqualThenData.
    Actually, why do you give the parameter a different name each time? Why not just pick something like rhs and use that for all of them. Seems to me it would make your life a lot easier.
    Actually, no, it's not a mistake. There is a word "then" and there is a word "than". If this equals that, then do this. If this is less than that, do this.
    Dunno. I just find making a little descriptive names better. Anyway, I changed them all to "Data" instead.

    Quote Originally Posted by iMalc View Post
    You're missing unary operator +.
    Quote Originally Posted by iMalc View Post
    If you want to prevent copying then your copy constructor and copy assignment operator need to take const references.
    Quote Originally Posted by iMalc View Post
    Operator << should take Data as a const reference.
    Missed those.

    Uploaded new files with more fixes.

    UPDATE: Proper include guard.
    Got rid of macros.

    UPDATE2:
    Re-ordered operators a little.
    Added global operators. All tests pass!
    Yes, even this:
    Code:
    MyInt = MyInt + MyInt - MyInt * MyInt / MyInt
    	&#37; MyInt & MyInt << MyInt >> MyInt ^ MyInt
    	| MyInt %= MyInt &= MyInt *= MyInt += MyInt 
    	-= MyInt /= MyInt <<= MyInt >>= MyInt ^= MyInt
    	|= MyInt;
    Last edited by Elysia; 03-17-2008 at 01:43 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. memory issue
    By t014y in forum C Programming
    Replies: 2
    Last Post: 02-21-2009, 12:37 AM
  2. Link List math
    By t014y in forum C Programming
    Replies: 17
    Last Post: 02-20-2009, 06:55 PM
  3. Looking for constructive criticism
    By wd_kendrick in forum C Programming
    Replies: 16
    Last Post: 05-28-2008, 09:42 AM
  4. No Match For Operator+ ???????
    By Paul22000 in forum C++ Programming
    Replies: 24
    Last Post: 05-14-2008, 10:53 AM
  5. load gif into program
    By willc0de4food in forum Windows Programming
    Replies: 14
    Last Post: 01-11-2006, 10:43 AM