473,320 Members | 2,048 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

casting operators

Hi can u please explain me the difference between <static_cast> and <dynamic_cast>....?
Feb 19 '08 #1
2 1281
gpraghuram
1,275 Expert 1GB
Hi can u please explain me the difference between <static_cast> and <dynamic_cast>....?
I think searching in the net will give you a good idea about this.
I suggest this link to start with.
After reading the tutorial you can come back here and post the questions

Raghuram
Feb 19 '08 #2
weaknessforcats
9,208 Expert Mod 8TB
The essential difference is that static_cast is a compile time cast whereas dynamic_cast is a runtime cast. That is, the types being used are checked at compile time for static_cast and runtime for dynamic_cast.

Also, dynamic_cast needs RTTI turned on to make that runtime type identification. That feature is a big resource hit.

Which leads me to: Why are you casting anyway??

These C++ cast forms are for emergencies and are not intended to be part of a design.
Feb 19 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

13
by: JustSomeGuy | last post by:
I have two object types ClassA and ClassB class ClassA { public: int data; operator ClassB() { ClassB b; b.data = data + 1; return (b);
16
by: He Shiming | last post by:
Hi, I'm having a little bit of trouble regarding pointer casting in my program. I don't understand why the following two cases produce different results. Case 1: IInterface *pInterface = new...
3
by: Andy Lomax | last post by:
I'm using a library where the supplier has provided base class 'foo', and a reference counting class which wraps 'foo': ------------------- library code ----------------------- template<class T>...
2
by: dave | last post by:
Why is this the same: (*(*pCurrent).pData).name as this: pCurrent->pData->name what is the benefit to the first? if any? why are the parenthesis important? thanks
6
by: Philipp Schumann | last post by:
Hi, I have a need for "dynamic type casting": in other words, in a "MyConvert" method I get passed an Object "value" and a Type "type" and the method should attempt to convert value into type. ...
18
by: Marco | last post by:
I need to get a iterator from any generic collection. public class .... GetIterator(Object collection) { ..... }
9
by: john | last post by:
I thought about this and I just want confirmation on that it's right If I do like this double b = 10.6; double c = 5.0; double a = (int)b / c; This will cast b to an int, and then divide it...
2
by: Giulio Petrucci | last post by:
Hi everybody, here's my problem: I have to dymanically build (and compile, of course) some code, from some ECMAScript function. ECMAScript variables I get are not typezed, so I should have...
4
by: techie | last post by:
I have defined a number of unsigned integer types as follows: typedef unsigned char uint8; typedef unsigned short uint16; typedef unsigned int uint32; typedfe long long uint64; Is it...
4
by: casul | last post by:
Hi All, Given the following code that just defines a dummy class "my_class" and a dummy wrapper "my_wrapper" with a main program : #include <iostream> template< typename _Tag > class...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.