The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
Google UNIX.COM


High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Help - Cast converts default int return type rtgreen High Level Programming 5 04-24-2007 10:15 AM
Dynamic SQl in KSH kousikan Shell Programming and Scripting 2 03-18-2007 08:12 AM
how to dynamic DNS bondoq Linux 1 11-14-2006 06:34 AM
Dynamic DNS [MA]Flying_Meat OS X (Apple) 0 12-06-2005 05:07 PM
dynamic pid? yls177 UNIX for Dummies Questions & Answers 2 12-17-2002 04:26 PM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 09-01-2005
Registered User
 

Join Date: Aug 2005
Posts: 38
why to use dynamic cast in c++

class base
{
public:
virtual void disp()
{cout<<"from base\n";}
};
class derv : public base
{
public:
void disp()
{cout<<"from der\n";}
};
int main()
{
base *b=new derv;
b->disp();
derv *d;
d=dynamic_cast<derv*>(b);
d->disp();
return(0);
}
///using dynamic cast the derived type pointer can point base type pointer..why it is necessary...where we should suppose to use this/////

int main()
{
int i;
int j;
char *a="hi friend how are you";
i=reinterpret_cast<int>(a);
j=(int)a;
cout<<i<<endl;
cout<<j<<endl;

return(0);
}
both will give the same output..then what is the difference b/w reinterpret and ordinary c style cast.....in static_cast also same thing we use c style instead of static_cast....

Last edited by sarwan; 09-01-2005 at 02:48 AM.
Reply With Quote
Google UNIX.COM
Forum Sponsor
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 04:54 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0