Click here to Skip to main content
14,694,717 members

Comments by ggupta2009 (Top 11 by date)

ggupta2009 17-Feb-12 1:04am View
   
Thank you very much...
ggupta2009 16-Feb-12 0:18am View
   
Is it due to standard-Input-buffer is not flushed (for scanf()) and before that printf() is called. But even then output should be initialized value of a? But as I have observed always output is 1?
ggupta2009 9-Feb-12 7:36am View
   
Hi,

I have added following inside main()

Derived2 obj3;
cout<<"size of Derived1 class is: "<<sizeof(Derived1)<<endl;
cout<<"size of Derived1 class object is: "<<sizeof(obj2)<<endl;
cout<<"size of Derived2 class is: "<<sizeof(Derived2)<<endl;
cout<<"size of Derived2 class object is: "<<sizeof(obj3)<<endl;

Output:
Value of Derived2Data is: 10.9
size of Derived1 class is: 1
size of Derived1 class object is: 1
size of Derived2 class is: 4
size of Derived2 class object is: 4
ggupta2009 9-Feb-12 7:28am View
   
Hi,
Even with dynamic_cast it is not working. Could you please comment on this?

I am coding like:
(dynamic_cast<diamondderived1*>(pBase))->DiamondDerived1Fun();

getting error: cannot dynamic_cast `pBase' (of type `class DiamondBase*') to type `class DiamondDerived1*' (source type is not polymorphic)
ggupta2009 9-Feb-12 7:19am View
   
Thanks a lot.
Link is helpful.
ggupta2009 9-Feb-12 7:19am View
   
Thank you very much.
::operator delete(chObjNew, 10); is working

Could you please tell why for "new" we need not to provide global-scope-resolution-operator?
ggupta2009 9-Feb-12 7:17am View
   
Thank you very much.
In this way "new" is working but somehow "delete" is still giving problem.

when I tried hit-and-trial.

following way code is running fine. could you please explain the situation briefly??

void* operator new[] (size_t t, int a)// working
{
cout<<"This is overloaded-new operator"<<endl;
cout<<"Parameter passed to oveloaded-new is: "<<a<<endl;
}

void operator delete (void* pointer, int iData, int iData1)// working
{
cout<<"This is overloaded-delete operator"<<endl;
cout<<"Parameter passed to oveloaded-new is: "<<iData<<endl;
cout<<"Parameter passed to oveloaded-new is: "<<iData1<<endl;
}

void main()
{
void* chObjNew = new(10)char[1];
::operator delete (chObjNew, 13, 14);
}

Output:
This is overloaded-new operator
Parameter passed to oveloaded-new is: 10
This is overloaded-delete operator
Parameter passed to oveloaded-new is: 13
Parameter passed to oveloaded-new is: 14
ggupta2009 14-Jul-11 10:50am View
   
Thank you very much...
can you please suggest which would be better alternate to do this?
ggupta2009 14-Jul-11 2:04am View
   
Thanks Chuck..
so, if I want to create array inside a function surely, I need to use dynamic allocation.
ggupta2009 14-Jul-11 2:03am View
   
Thank you very much Christian..
I got my answer
ggupta2009 14-Jul-11 1:02am View
   
Thank you very much barneyman.

I got a good idea from your solution.