HI All ,:)
I am a VC++ programmer,and some time My <b>Acumen</b> ask Microsofts
VC++ (Visual Studio VC++ 6.0 )complier to complile my <b>senseless
programs </b> ! :)
<i><b>
See what I have asked this time to compile !!..</b></i>
This is console based program, in which i am trying to call Member
function of My class With a NULL pointer .
And it is working fine....:cool:
Please some one explain this to me ....is this happening of coz Compiler
is fed up with my programs !! :-D
#include "stdafx.h"
#include <iostream.h>
class A
{
public :
int var;
A()
{
cout<<"In Consrtuctor !!";
}
~A()
{
cout<<"\nClass destroyed !!\n";
}
void EvenNullPointerCanCallme(int a);
};
void A::EvenNullPointerCanCallme(int a)
{
int *aa=new int[100];
cout<<"\nHow is that possible !!\n";
delete []aa;
}
int main(int argc, char* argv[])
{
A *nullPtr=NULL;//see i made it NULL
nullPtr->EvenNullPointerCanCallme(2);//How daring i am :)
delete nullPtr;//I cannot call destructor !
return 0;
}
Are member functions statically linked with the Object name !!
Actually i never found any concept of accessing Class member function
with NULL pointers in Any of C++ books Which I have read (Plz let me
know if u people have found it in any book !).
I am grateful to all u peoples who had a look at my program !!
Now see i am getting famous or what :)
--
Abhishek Srivastava
Software engg
India , Noida
:)
Posted via
http://dbforums.com