answersLogoWhite

0

There are two methods of casting one type to another: static casting and dynamic casting (both of which apply to pointers and references to objects). Statically casting a derived class to a base class is typesafe as the base class is guaranteed to exist if the derived class exists. However, static casting from a base class to a derived class is always considered dangerous as the conversion is not typesafe. Dynamic casting exists to cater for this scenario, however it is only possible when the base class is polymorphic (thus ensuring the required runtime information is available). If the conversion is not possible, the return value is NULL. However, it is considered bad programming practice to dynamically cast from a base class to a derived class. If the base class is polymorphic (which it must be), there is NEVER any need to dynamically cast between types. Virtual methods ensure correct behaviour. Whenever you are forced to dynamically cast from a base class to a derived class, consider redesigning the base class interface instead, as it is a clear sign of bad design. It is not dangerous, however; only static casting from a base class to a derived class is considered dangerous.

User Avatar

Wiki User

12y ago

What else can I help you with?

Continue Learning about Engineering

What are the importance of turbo c?

i came to know about that turbo c compiler is having 32 number of disadvantages........ i know about 10-12 disadvantages and i am sharing those wid u .... 1) Turbo c is a 16bit compiler ... means it can access about 16bits of data at a time... 2)Turbo c is based upon 8086 microprocessor... and it can run on x86family.... 3) Turbo c is derived from MS-DOS whereas GCC compiler which runs on linux..is a very good one as compared to Turbo C compiler..,.. 4)Also we cant do ODBC and Networking programming over the Turbo C comiler whereas we can do above programming in GCC compiler successfully by installing one ODBC library in it.... 5)we cant do graphics programming over here, rather we can do graphics programming. in GCC compiler using Glad Interface... 6) Turbo C compiler can access only 1mb of RAM, which is a demerit...whereas GCC compiler can access 4gb OF MEMORY.. 7) 7) Turbo C compiler is based upon MS DOS operating system.. which is a single process operating system..whereas GCC Compiler is based on 80386 processor(LINUX) and it is multiprocess operating system.....


What is late bound function call in C plus plus?

Late binding, or dynamic binding, occurs at runtime. Early binding, or static binding, occurs at compile time. The difference between the two is that, with early binding, the compiler knows exactly which function will be called in advance and can statically bind to that function during compilation. With late binding, the compiler does not know which function will be called in advance, it only knows the function signature. Thus the binding has to be done at runtime. For example, if you call a virtual function of a base class, the compiler cannot determine in advance the exact type of the derivative (in some cases it may not be derived at all). All it knows is that you've called the base class method and that an override may or may not exist at runtime. Thus the exact method to be called will ultimately be determined at runtime, via the derived class' virtual table. Note that although the derived class is itself late bound (because the compiler cannot know the exact type of a derivative that may be made available in the future), only the virtual methods of the base class need to be late bound. Non-virtual methods can be statically bound, since they are never expected to be overridden. Calling virtual methods is actually no different to using function pointers within your code (a virtual table is simply an array of function pointers, with one table per base class, and another for each of its derivatives). Again, the compiler cannot know in advance where a function pointer will actually be pointing at compile time, thus the call must be dynamically bound at runtime.


What is ambiguity in hybrid inheritance How ambiguity remove from compile time examples?

Ambiguity in hybrid inheritance occurs when a derived class inherits from multiple base classes that have methods or attributes with the same name, leading to confusion about which method or attribute should be invoked. This can create issues in compile time, as the compiler cannot determine the correct method to use. To resolve ambiguity, developers can use explicit scope resolution (like ClassName::methodName) or override methods in the derived class to provide a clear implementation. For example, if both base classes have a method display(), the derived class can override it to specify its behavior and eliminate ambiguity.


How does virtual function support run time polymorphism?

Virtual functions are used to suport runtime polymorphism.In C++,if we have inheritance and we have overridden functions in the inherited classes,we can declare a base class pointer and make it to point to the objects of derived classes.When we give a keyword virtual to the base class functions,the compiler will no do static binding,so during runtime ,the base class pointer can be used to call the functions of the derived classes.Thus virtual functions support dynamic polymorphism.


Can a constructor be declared as virtual?

A constructor cannot be virtual because at the time when the constructor is invoked the virtual table would not be available in the memory. Hence we cannot have a virtual constructor. ## Constructor called implicitly not explicitly so constructor is not virtual.

Related Questions

What do scientist consider when they perform a cladistic analysis?

They consider derived characters.


Is derived and translated the same thing?

No, they are not the same. "Derived" refers to something that comes from a source or origin. "Translated" refers to converting text or information from one language to another. So, while both involve the transformation of something, they involve different types of transformation.


What are the importance of turbo c?

i came to know about that turbo c compiler is having 32 number of disadvantages........ i know about 10-12 disadvantages and i am sharing those wid u .... 1) Turbo c is a 16bit compiler ... means it can access about 16bits of data at a time... 2)Turbo c is based upon 8086 microprocessor... and it can run on x86family.... 3) Turbo c is derived from MS-DOS whereas GCC compiler which runs on linux..is a very good one as compared to Turbo C compiler..,.. 4)Also we cant do ODBC and Networking programming over the Turbo C comiler whereas we can do above programming in GCC compiler successfully by installing one ODBC library in it.... 5)we cant do graphics programming over here, rather we can do graphics programming. in GCC compiler using Glad Interface... 6) Turbo C compiler can access only 1mb of RAM, which is a demerit...whereas GCC compiler can access 4gb OF MEMORY.. 7) 7) Turbo C compiler is based upon MS DOS operating system.. which is a single process operating system..whereas GCC Compiler is based on 80386 processor(LINUX) and it is multiprocess operating system.....


Does compile time depend on instance characteristics?

Yes. Although dynamic binding occurs at runtime, the compiler ensures that all runtime instances are covariant with compile time types. That is, you cannot instantiate a base class pointer to a derived type that is not covariant with the base class. The derived type must have an "is-a" relationship or the compilation will fail.


How many 250grams in 250kilpograms?

There are 1000 250-gram portions in 250 kilograms. This calculation is derived from converting the kilograms to grams and then dividing by the weight of one 250-gram portion.


What does amok mean?

Amok means "out of control", especially when armed and dangerous, or in a frenzy of violence - derived literally from the Malay for "to go on a killing spree".


When you define a c plus plus class what items are considered part of the interface?

The interface of a C++ class is the public methods and attributes that are exposed by the class. In a pure abstract base class, the interface is enforced by the compiler in each of the derived child classes.


What is the origin of the word deliberate?

The word "deliberate" comes from the Latin word "deliberatus," which is derived from the verb "deliberare," meaning "to consider carefully."


What is the name origin of tsutsugamushi disease?

The name tsutsugamushi is derived from two Japanese words: tsutsuga, meaning something small and dangerous, and mushi, meaning creature.


Which star systems were derived from various Star Wars sources to put in the Essential Atlas?

The star systems were derived from various Star Wars sources to put in the Essential Atlas and online companion are:Abaar - derived from Abaarian waterAlarevi - derived from Alarevi aleAlui - derived from Alui CorridorAncathia - derived from Ancathian funge-flowerAngeria - derived from Angerian Fishak SurpriseAngrallia - derived from Angrallian ToobirAnorelga - derived from Anorelgan slip-sockerAntakaria - derived from Antakarian Fire DancerApoka - derived from Apokan silveroakArdroxia - derived from Ardroxian fluAridinia - derived from Aridinian folk musicAskaria - derived from Askarian wormBacia - derived from Bacian blood hornetBactriasa - derived from Bactriasan scarabBaldur - derived from Balduran Civil WarBanasthau - derived from BanasthaurBarbeen - derived from Brothers of BarbeenBarcaria - derived from Barcarian claw saltBatravia - derived from Batravian gumpluckerBelloria - derived from Bellorian aleBelvaria - derived from Belvarian firegnatBenwabula - derived from Benwabulan gongBesnia - derived from Besnian sausageBiravia - derived from BiravianBisellia - derived from Lobster BisellianBiskar - derived from Biskaran PiratesBizikia - derived from Bizikian hornetBloxia - derived from BloxianBolenia - derived from Bolenian hillspinnerBontormia - derived from Bontormian KlesplongBorloria - derived from Borlorian Breta Yaga - derived from Breta Yagan flatsculpBruvia - derived from BruvianBynarria - derived from Bynarrian jigCamblia - derived from Camblian OrderCandoria - derived from Candorian plagueCardellia - derived from Cardellian mintCarpagia - derived from CarpagianCartusio - derived from Cartusion whaleCaska - derived from Caskan wolf-snakeCedrell - derived from Cedrellian aged wineCerilia - derived from Cerilian Trade AgreementChagaria - derived from Chagarian ale Changa - derived from Changan bushfightingCharbodia - derived from CharbodianCheku - derived from ChekutCheruba - derived from Cheruban glachChestrashus - derived from ChestrashiCornesia - derived from Cornesian waxCorosi - derived from Corosian phoenixCorthenia - derived from CorthenianCorweillia - derived from CorweillianCrintlia - derived from CrintlianCydorria - derived from Cydorrian driller treeD'faria - derived from D'farianDairka - derived from Dairkan StarlinerDarellia - derived from Darellian fire crabDaruvvia - derived from Daruvvian champagneDarwikia - derived from Darwikian climbing padDbari - derived from DbarianDelmaas - derived from Delmaasi piratesDelphania - derived from DelphanianDeluvia - derived from Deluvian fatwormDenbar - derived from 543rd Denbari Attack CompanyDenebia - derived from Denebian holo-chessDenebrilla - derived from Denebrillan star silkDeneeli - derived from Deneelian fizz-puddingDenusia - derived from Denusian squirmerDervdis - derived from Dervdisi business suitDeryvia - derived from Deryvian snakeDimea - derived from DimeanDirellia - derived from Direllian PlagueDoreen - derived from Doreenian ambergrisDorenia - derived from Dorenian BeshniquelDozoisia - derived from Dozoisian snark venomDramassia - derived from Dramassian silkDressia - derived from Dressian Kiolsh Merchant BankDrilbia - derived from Drilbian wineDruulgotha - derived from DruulgothanDubloviann - derived from Dubloviann flame rifleEilnia - derived from Eilnian sweet flyEmorus - derived from Emori leatherworkEmurria - derived from Emurrian operaEndrolia - derived from Endrolian ground-apple JuiceErtrax - derived from ErtraxiFalasia - derived from Falasian liquid crystalFeraleech - derived from Feraleechi Onetime LoopFerijia - derived from Ferijian apeFerrelia - derived from Ferrelian antFlandor - derived from Flandorian flowerFligger - derived from Fliggerian firebeastFlyntaria - derived from Flyntarian tabac stickForbelea - derived from Forbelean DefenseFroffl - derived from FroffliFromish - derived from Fromish aleFrunchettan - derived from Frunchettan-saiGaddria - derived from GaddrianGarwillia - derived from Garwillian champagneGaldria - derived from Galdrian mustangGaldronia - derived from Beneath the Galdronian Moon: A Modern Lover's EpicGannymeda - derived from GannymedanGeillia - derived from Geillian aleGelda - derived from Geldan sun-appleGerinia - derived from Gerinian star-stoneGgy-ynt - derived from Bandits of Ggy-yntGhothia - derived from Ghothian slimeGorgaria - derived from Gorgarian buzzadderGravdinia - derived from Gravdinian aleGregonia - derived from Gregonian salamanderGrimwald - derived from Grimwaldi spongeGurrisalia - derived from Sacred Scroll of GurrisaliaGuudria - derived from GuudrianGuuko - derived from GuukosiHaluria - derived from Halurian ice boarHarda - derived from Hardan plagueHarterra - derived from Harterran moonstoneHaseria - derived from HaserianHasiki - derived from HasikianHassaria - derived from HassarianHeliconia - derived from Yellow-barred Heliconian butterflyHeptalia - derived from Heptalian embroidered throwHillindor - derived from Hillindor game fowlHismaul - derived from Hismauli hawk-snakeHrthging - derived from Hrthgingian FiregemHuulia - derived from Huulian starfighterHuvveck - derived from University of HuvveckHylaia - derived from Hylaian marsh bambooIdolia - derived from Idolian fever Ipellrilla - derived from Ipellrillan firewaterIlthan - derived from Ilthani space mineImerria - derived from Imerrian windstormIskin - derived from Star of IskinIxzinia - derived from Ixzinian rock ramJaciprus - derived from JacipriJakelia - derived from Jakelian knife-danceJalin - derived from Jalinese knifeJalor - derived from Jalorian SodalityJargridia - derived from Jargridian brandyJavarica - derived from Javarican espressoJendiria - derived from Jendirian ValleyJexeria - derived from Jexerian cannonJhantoria - derived from Jhantorian wineJohria- derived from Johrian whiskeyJovaria - derived from Jovarian sun fernJunobia - derived from Junobian sand flierJurio - derived from Juriod fang-flierKallakea - derived from Kallakean rainbowKareas - derived from Kareas brandyKarka - derived from Karkan ribeneKarlinus - derived from Karlini teaKarltonia - derived from Karltonian fiskinKarthrexia - derived from Karthrexian glacierKatalia - derived from Katalian apeKayven - derived from Kayven wistlerKedra - derived from Kedran lipsmearKeitum - derived from KeitumiteKexeeria - derived from Kexeerian Blasters TechnologyKhomr - derived from Khomri tapestryKiliea - derived from Kiliean bolt gunKintarr - derived from Kintarrian death drumKlepthia - derived from Klepthian rock otterKler'terria - derived from Kler'terrianKloodavia - derived from KloodavianKlytonia - derived from KlytonianKobaria - derived from Kobarian swamp dogKoolach - derived from Koolach silkKragis - derived from Bloodboilers of KragisKurdavvia - derived from Kurdavvian sunriseKyoloria - derived from Kyolorian snake-godLaerdocia - derived from LaerdocianLambaria - derived from Lambarian crabLerct - derived from Lerct Historical InstituteLhosa - derived from Lhosan IndustriesLoedorvia - derived from Loedorvian brain plagueLofquar - derived from Lofquarian gooney birdLovetus - derived from Loveti mothLucrusia - derived from Lucrusian fengrillLuduria - derived from Ludurian nose fluteLurania - derived from Luranian brandyLust - derived from Lost Sultans of LustLuudria - derived from Luudrian lockjawLythia - derived from Lythian PiratesMa'alkerr - derived from Ma'alkerriteMaerdocia - derived from MaerdocianMagravia - derived from Magravian cat-spiceMalari - derived from MalarianMaldovea - derived from Maldovean burtalleManaxia - derived from Manaxian amberManella - derived from Manellan jasperMarcadia - derived from Marcadian luxury cruiserMavinia - derived from Mavinian cluster-wedding organMelahna - derived from Melahnese cuisineMelus - derived from Melusi UprisingMendacia - derived from Mendacian funeral urnMerthia - derived from Merthian lung infectionMeshakia - derived from MeshakianMessia - derived from Messian flame lizardMirnic - derived from Mirnic UniversityMiv'rah - derived from Miv'rah FirestormMoloskia - derived from MoloskianMoobia - derived from Moobian torsion valveMoravia - derived from Moravian maneuverMorturia - derived from Morturian energy diskMuzzli - derived from Muzzlian squillMyrenia - derived from MyreniaNatalon - derived from Natalon Core BanditsNeoli - derived from NeolianNerria - derived from NerrianNilgaria -derived from Nilgarian wormNimgorrhea - derived from Nimgorrhean saber waspNirellia - derived from Nirellian ground slugNomaria - derived from Nomarian thunder sharkNooli - derived from Noolian CrisisNorkronia - derived from Norkronian whistle snakeNoryath - derived from Noryath meatbreadNotonia - derived from Notonian mudwormNuala - derived from Nuala maraudersNumatra - derived from Numatra snakeNymalia - derived from Nymalian water-oxOctavia - derived from Octavian fruit puddingOnderia - derived from Onderian raptorOracaia - derived from Oracaian customs frigateOrkellia - derived from Orkellian cave slug Oshora - derived from Oshoran rainbow pearl necklaceOssiathora - derived from Ossiathoran noodleOsskorn - derived from Osskorn StoutP'frorin - derived from P'frorin gotta-wormPanela - derived from Panelan feastParliock - derived from Peacekeeping of ParliockParwa - derived from Parwan nutricakePerthrillia - derived from Perthrillian nightwaspPervi - derived from Pervian blood crowPervick - derived from Pervickian dung camelPhibia - derived from Phibian beerPhr'sha - derived from Phr'shan maneuverPiluvia - derived from Piluvian salamanderPlavonia - derived from Plavonian starfishPolordio - derived from Polordion smootdustPortminia - derived from PortminianPyolli - derived from Pyollian cakeQonto - derived from QontoQuilan -derived from Quilan PyradexQuooria - derived from Quoorian marshsuckerRamordia - derived from Ramordian silkRamorea - derived from Ramorean capanataRazia - derived from Razian psycho stormRbollea - derived from Rbollean petal-oilRhuvia - derived from Rhuvian fizzRigovia -derived from Rigovian Technical UniversityRindoon - derived from Rindoon DartRivoria - derived from Rivorian grain-banditRubogea - derived from Rubogean GambitRulaar - derived from Rulaarian pleasure yachtRuloosia - derived from Ruloosian sand snakeRurgavea - derived from Rurgavean SleightRyborea - derived from Ryborean gaxSalagor - derived from 43rd Salagori LancersSandonia - derived from Sandonian 4XA Prensile CruiserSantheria - derived from Santherian tenho-rootSarkania - derived from Sarkanian jellySewalia - derived from Sewalian algae crispsSha'rellia - derived from Sha'rellian toopSileria - derived from Silerian StallSontara - derived from Sontaran song ballSorderia - derived from Sorderian wetfabricSormahil - derived from Sormahil fire gemSpanthaer - derived from Spanthaer lava lampSuria - derived from Surian teaTarchalia - derived from Tarchalian gazelleTarlandia - derived from Pride of TarlandiaTarmidia - derived from Old TarmidianTartaria - derived from Tartarian mouseTedonia - derived from Tedonian wineTellanada - derived from Tellanadan moonflowerTellivar - derived from Tellivar LadyTheselon - derived from Theselonian bridal gownTolfrania - derived from Tolfranian briefTourani - derived from Touranian jumping stoneTrupellia - derived from Trupellian probabilityTyaonon - derived from Tyaonon Ranger Utrica - from X-Wing AllianceUlmatra - derived from Ulmatran condorUthor - derived from Uthori breixVadooria - derived from Vadoorian sniffer ratVanaria -derived from Vanarian tree eaterVectinia - derived from Vectinian spiderVenedlia - derived from Venedlian sandmole Vendusii - derived from Vendusii crystalVelanaria - derived from Velanarian boxingVelossia - derived from Velossian Caramachi Shell-backVerdanaia - derived from Verdanaian "Sliding Hands" methodVerdi - derived from Verdian vine beanVerdoria - derived from Verdorian fire ratVerossia - derived from Verossian computerVerullia - derived from Verullian land slugVorkaa - derived from VorkaanVorsia - derived from Vorsian crystalVrakolia - derived from VrakolianVulderania - derived from Vulderanian grain flakesWerania - derived from Weranian holocardWhelori - derived from Whelorian snake-eaterWrodi - derived from Wrodian carpetXandonia - derived from Xandonian night terrorXerthia - derived from Xerthian hound-slugYagara - derived from Yagaran aleudrupe plantYankirk - derived from Yankirk RouteYantha - derived from YanthanYartiga - derived from Yartigan well waterYchthyton - derived from YchthytonianYutan - derived from Middle YutaneseZadaria - derived from Zadarian brandyZeolosia - derived from ZeolosianZobbera - derived from Zobberan hound Zybahhod - derived from Zybahhod YenyoniZygia - derived from Zygian Savings and Loanetc.


Do lines have to be straight?

Yes. Consider the drawing of a table. ~ Actually, a circle is the set of all points at a given distance from the center. It's technically not derived from a line.


What makes hydrochloride a dangerous substance?

Hydrochloride is derived from hydrochloric acid combining with an organic base. Hydrochloric acid is very corrosive, both to materials and to tissues of the human body.