dubeyprateek 26 Junior Poster

how about trying this

#include <Windows.h>

BOOL MySystemShutdown()
{
	HANDLE hToken; 
	TOKEN_PRIVILEGES tkp; 

	// Get a token for this process. 

	if (!OpenProcessToken(GetCurrentProcess(), 
		TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken)) 
		return( FALSE ); 

	// Get the LUID for the shutdown privilege. 

	LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, 
		&tkp.Privileges[0].Luid); 

	tkp.PrivilegeCount = 1;  // one privilege to set    
	tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; 

	// Get the shutdown privilege for this process. 

	AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, 
		(PTOKEN_PRIVILEGES)NULL, 0); 

	if (GetLastError() != ERROR_SUCCESS) 
		return FALSE; 

	// Shut down the system and force all applications to close. 

	if (!ExitWindowsEx(EWX_SHUTDOWN | EWX_FORCE, 
		SHTDN_REASON_MAJOR_OPERATINGSYSTEM |
		SHTDN_REASON_MINOR_UPGRADE |
		SHTDN_REASON_FLAG_PLANNED)) 
		return FALSE; 

	return TRUE;
}
int _tmain(int argc, _TCHAR* argv[])
{
	MySystemShutdown();
	return 0;
}
dubeyprateek 26 Junior Poster

Seems I could not present myself correctly...
Heap and Virtual memory are different
see this for heaps
http://msdn2.microsoft.com/en-us/library/aa366711(VS.85).aspx
This http://msdn2.microsoft.com/en-us/library/aa366599.aspx cluearly states why allocations grater in size do not fails.
Heap manager manages heaps it is a part og Windows memory manager.

You can see "Windows Internals 4th Edition" or you can use Windbg to see the implimentational details of heaps in Windows.

Heap Manager
Many applications allocate smaller blocks than the 64-KB minimum allocation granularity possible using page granularity functions such as VirtualAlloc. Allocating such a large area for relatively small allocations is not optimal from the memory usage and performance standpoint. To address this need, Windows provides a component called the heap manager, which manages allocations inside larger memory areas reserved using the page granularity memory allocation functions. The allocation granularity in the heap manager is relatively small: 8 bytes on 32-bit systems and 16 bytes on 64-bit systems. The heap manager has been designed to optimize memory usage and performance in the case of these smaller allocations.
The heap manager exists in two places: Ntdll.dll and Ntoskrnl.exe. The subsystem APIs (such as the Windows heap APIs) call the functions in Ntdll, and various executive components and device drivers call the functions in Ntoskrnl. Its native interfaces (prefixed with Rtl) are available only for use in internal Windows components or kernel mode device drivers. The documented Windows API interface to the heap (prefixed with …

Ancient Dragon commented: great explaination +21
dubeyprateek 26 Junior Poster

You are not moving the cursor at right place before you do a "cout"
Ycan move cursor by including one more function in your point class
in point.h
add a member funtion in the point class

void gotoxy(int , int ) const ;

in point .cpp add following.

void Point::gotoxy(int x, int y) const
{
	HANDLE hConsoleOutput;
	COORD Cursor_Pos = {x, y};

	hConsoleOutput = GetStdHandle(STD_OUTPUT_HANDLE);
	SetConsoleCursorPosition(hConsoleOutput, Cursor_Pos);
}

use it in your draw member function

void Point::draw() const
{
	gotoxy(x,y);
	cout<<".";
}
Max_Payne commented: Solved a problem a lot of people couldn't solve. +1
invisal commented: I have to admit this, it is hell alot of code to read, and you manage to solve it. +3
dubeyprateek 26 Junior Poster

You can use component object modeling, runtime polymorphism, Pure virtual functions.

Dlls (Dynamicly linked library)

Thanks,
Prateek

Jishnu commented: Thanks :) +2
dubeyprateek 26 Junior Poster

Why is that so?

Two reasons::
1) Microsoft may change behaviour of these APIs without any notifications. Therefore your application may break.
2) Microsoft does not 'supports' usage of thses APIs.

dubeyprateek 26 Junior Poster

hi
There are two things first

const double *highest = a;

this line says highest is a pointer to a costant means u cant change the content highest is pointing to, next

if (a[i] > *highest)
        {
            *highest == a[i]; // "==" ??
        }

removing that if u do it like

if (a[i] > *highest)
        {
            *highest = a[i];
        }

u will be trying to change a contant, which is illegal.

better if u write

const double * maximum(const double a[], int size)
{
    if (size == 0) return NULL;
    double *highest = (double*)a;
    for (int i = 0; i < size; i++)
        if (a[i] > *highest)
        {
            *highest = a[i];
        }
    return highest;
}