C++ Part4

Why do C++ compilers need name mangling?

Name mangling is the rule according to which C++ changes function’s name into function signature before passing that function to a linker. This is how the linker differentiates between different functions with the same name.

Is there anything you can do in C++ that you cannot do in C?

No. There is nothing you can do in C++ that you cannot do in C. After all you can write a C++ compiler in C. 



This is my little collection of C++ Tipps/Tricks/little known facts.
Every time i discover something worth adding, i will put it here.

1. Discovering Memory Leaks
3. Exact Time Measuring
4. Functionpointer to class memberfunctions
5. Setting Fullscreen mode under windows
6. Know thy stringstreams
7. std::sort with non-static compare-method in a class

1. Discovering Memory Leaks
Of course if you are working on a serious project you will use a sophisticated memory manager that will also discover memory leaks (along with their exact position in the code), but if you just want to do a quick test there is an easy way to let the debugger check for memory leaks:
– Include crtdbg.h in your project.
– At the beginning of you main() / WinMain () put this code:

int flag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);

This works in VC++ ( i don’t know about other compilers tho ) and, if you run the programm in debug mode (Hit F5), it will report memory leaks in the debug output window.

You have propably heard about the assembler instruction CPUID and RDTSC, which are supported by VC++ 6 and higher, but if you have an older compiler you can make use of the __emit function. This is a pseudo-asm instruction that lets you insert bytes directly into the outputted .exe. So, with a compiler that doesn’t know the cpuid/rdtsc instuctions we can just use a little macro to put their respective opcodes directly as binary values into our program:

#define rdtsc __asm __emit 0fh __asm __emit 031h
#define cpuid __asm __emit 0fh __asm __emit 0a2h


4 Responses to “C++ Part4”

  1. diavolaki Says:

    plz i need this aplication

  2. manoj Says:

    actully i leran c, c++ but who to use and how to downlod me..

  3. Ababneh Says:

    please i really need a help here ..
    i have a project and i must finish it before a specific time..
    anyone intrested ?
    please ..

  4. natasha Says:

    dear sorry mujhe c++ aati hai but mai aap ki help nhikar sakti

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: