Item Not Found Issue Fix (Windows)

You’ve probably experienced this one at some point in your work, but it can be quite annoying. Fortunately, all you have to do is navigate to the directory in which the item/s (file or folder) is/are located, use [dir /x] and then delete each item manually with [rmdir /q /s name-of-the-directory].  

Powers of two (Pascal)


program PowersOfTwo;

const
   limit = 10;

var
   number : longint;

begin    
   number := 1;
   
   while number <= limit do
      begin
         write(number:3);
         number := number << 1;
      end;  
end.     

Basic tracking algorithm (C++)

I recently used this one in an SDL 2D framework and it is quite simple and effective. 


void DummyTracker::Track(const Player& player)
{
	Vector2D target = player.Position(); 

	// Basic chase algorithm
	if (m_position.x > target.x)
		--m_position.x;

	else if (m_position.x < target.x)
		++m_position.x; 

	if (m_position.y > target.y)
		--m_position.y; 

	else if (m_position.y < target.y)
		++m_position.y;
}

Static functions vs unnamed namespaces (C++)

Use of static for isolating functions in translation unit(s) has an interesting story itself; it was depricated in C++98 and then “revitalized” again in C++11. Unnamed namespaces have some advantages over static functions, but they could lead to modules that are not visible in the debugger. Still, unnamed namespaces let you nest functions at a desired level. Also, namespaces apply to types as well, unlike static (refer to the previous post). 

Static/Extern Type: Is it possible?

No.

The static/extern linkage specifiers always refer to an object or a function. 

static class X
{
    ...
} x_instance; // static instance!

X another_x_instance; // not static!