why in the world would you ever upcast? Programming Software Development by lochnessmonster i dont see the point or why you would ever want to upcast an object for example class Shape { ..... }; class rectangle : public shape { .... }; int main() { rectangle object1; Shape *shapePtr = &object1; return 0; } Re: why in the world would you ever upcast? Programming Software Development by mike_2000_17 … example is a straw-man, you would not want to upcast in that case. One of the main points of Object… How to acces Command Object in ADO executeComplete event Programming Software Development by JoutPerl … names, values, etc. inside this event handler? First, tried to upcast, but it didn´t work [code] void __fastcall TDm::ADOCnnClientesExecuteComplete… upcasting and downcasting? Programming Software Development by lochnessmonster im curious as to why in the world anyone would ever upcast or even downcast an object in their program? [CODE]class shape { }; class circle : public shape { }; int main () { circle a; shape b; b = (shape)a; return 0; }[/CODE] Re: Run time casting error Programming Software Development by Ezzaral Can you move the conditional portion into "C" and just leave the call as "ob.myMethod()"? You can't expect to upcast a "B" object to a "C". If you can't let the conditional be handled polymorphically, you'll have to add an "instanceof" test prior to the upcast and method invocation. Re: Write a program that displays the table of Fahrenheit - Celsius temperatures. Programming Software Development by StuXYZ … operation involving one double and one integer, the integer is upcast to a a double and a double is evaluated. e…/3 is done before - and produces an integer (1). The upcast is only for each pair in the expression and the… Re: Dynamic cast vs static_cast Programming Software Development by nitin1 …, this one. Employee is base class. Employee employee; Programmer programmer; // upcast - implicit upcast allowed Employee *pEmp = &programmer; // downcast - explicit type cast… Re: Vector and virtual function questions Programming Software Development by Alex Edwards … the Base's method is called. --That is, when you upcast the Derived into a Base pointer... not just all the… Re: abstract and interfaces Programming Software Development by kvprajapati …++’s “multiple inheritance,” by creating a class that can be upcast to more than one base type. [B]Characteristics of Interfaces… Re: C# Crystal Reports changing database and server name Programming Software Development by DdoubleD … is installed?[/QUOTE] Hi, I think you only need to upcast your report object to a ReportDocument. So in the example… Re: C# Crystal Reports changing database and server name Programming Software Development by DdoubleD … rpt = new DemoReport(); // your embedded document ReportDocument crDoc = (ReportDocument)rpt; // upcast ReportSourceSetup(crDoc, crConnectionInfo); // table logon info setup public void ReportSourceSetup… Re: Creating an array of objects Programming Software Development by nobodycool … read last night that this is because I have to upcast to the parent object. Is this the case? Is there… Re: Creating an array of objects Programming Software Development by javaAddict … read last night that this is because I have to upcast to the parent object. [/QUOTE] I ran this: [CODE] Music… Re: Not responding when run.. Programming Software Development by hao90 ….ignore(); getchar(); return 0; } [/CODE] ok well..i delete the upcast thing..but how to call the function from savingAccount if… Re: Type "long" variable: why is this happening? Programming Software Development by java_programmer …, it will first treat the literal as int and then upcast it to long. As the literal you used, is out… Re: Class hierarchy Programming Software Development by mike_2000_17 …: Do not use a "reinterpret_cast" to do an upcast or a downcast of pointers between two non-void types… Re: new, malloc and a class Programming Software Development by sepp2k …`? PS: You shouldn't use explicit casts to perform an upcast. That makes it harder to see when you perform a… Re: Dynamic cast vs static_cast Programming Software Development by sepp2k … *pb = dynamic_cast<Base*>(&d); This is an upcast. Using `dynamic_cast` here is pointless as the cast is always… Re: why in the world would you ever upcast? Programming Software Development by L7Sqr Having a collection of Shapes would be terribly difficult if you has to have a separate container for each type of Shape you had. Casting to a Shape pointer allows you to store any type of Shape in a single container and still have it operate appropriately. Re: why in the world would you ever upcast? Programming Software Development by thekashyap Mike already gave an excellent example. Just to point out in different words. In a good design you want abstraction. And that's provided by inheritance (among other options) primarily. As long as users use abstractions (Shape in this case) they're shielded from implementation details. A good example from "Java" is: [CODE=java] … Re: upcasting and downcasting? Programming Software Development by Momerath Let us say we have a base class known as Animal that has a virtual method Eat. We derive some child classes Lion, Bear, Bird. Now we want to have a collection of these creatures and since they all derive from Animal, we can create an Animal array and instantiate as many of the child classes and store them in the array (up casting). We can then … Re: upcasting and downcasting? Programming Software Development by mrnutty To enable [B]polymorphism[/B]