vc crtdbg detect the memory leaks of static variables by mistake

### Advertisement

### Categories

Handy snippets of code

vc crtdbg detect the memory leaks of static variables by mistake

See on the source (url)

Given n points, find two points with the smallest distance to each other. The examples listed below demonstrate two algorithms in C++ to tackle this problem. One algorithm simply checks every combination of points, also known as a brute force approach. The other one is an efficient algorithm which uses a divide and conquer approach. The [...]

Posted in C++ Also tagged algorithm, brute force, closes pair of points, cpp, distance, divide and conquer, dots, geometry, programming, vector 2 Comments

Matrices can be used to perform transformations. For example, in 2D and 3D space. Transformations include, but are not limited to, rotating, scaling and translating. Transformations can be combined by multiplying the matrices with each other. For example, you might want to: scale an object with a factor of 2 rotate it 45 degrees around the [...]

Posted in C++ Also tagged 2d, 3d, console application, gaming, identity, matrix, multiplication, programming, rotating, scaling, transformation, translating, vc++, vector 2 Comments

A common problem when drawing with GDI in VC++ is that the screen might flicker when you’re doing a lot of drawing. This problem can be overcome by drawing on a so called back buffer. The back buffer is then drawn at once. I’ve created a Win32 project in VC++ to demonstrate this. The first [...]

Posted in C++ Also tagged back buffer, brush, device context, double buffering, drawing, flickering, gaming, gdi, graphics, programming, rectangle, win32 Leave a comment

This example extends the Vector2 and Vector3 classes from the 2D and 3D vector normalization and angle calculation in C++ example. The formulas for distance calculation in 2D and 3D are listed below.

Posted in C++ Also tagged 2d, 3d, distance, euclidean space, gaming, graphics, programming, vector Leave a comment

Normalizing a vector can derive the direction of the vector in 2D or 3D space. A normalized vector is also known as a unit vector. We’re going to normalize and calculate the angles of a 2D vector at position (5,5) and a 3D vector at position (5,5,5). This can come in very handy when, for [...]

Posted in C++ Also tagged 2d, 3d, atan, atan2, azimuthal angle, class, degrees, formula, gaming, header file, math, normalization, phi, pi, polar angle, radians, radians to degrees, radius, spherical coordinates, square root, theta, unit vector, vector, vector length 2 Comments

C++ can be used for object-oriented programming. This example shows you how to define a class and a header file belonging to it.

Posted in C++ Also tagged class, console, instance, object, object pointer, object-oriented, oop, programming Leave a comment

Pointers in C++ are used to point to a location in memory. The memory address is stored in the pointer. Suppose we have a temperature variable of type float and a pointer which points to a variable of type float.