473,383 Members | 1,821 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,383 software developers and data experts.

Checking the type of a up casted class

Hi, I want to check the type of a derived unmanaged class, upcasted to
it's base class in CLI. Basically, I have several c++ classes that
derive from a single abstract base class. I'm passing the base class
in, and I want to check the type, and cast it later. Please advise.

Jun 21 '07 #1
1 890

"DaTurk" <mm******@hotmail.comwrote in message
news:11**********************@c77g2000hse.googlegr oups.com...
Hi, I want to check the type of a derived unmanaged class, upcasted to
it's base class in CLI. Basically, I have several c++ classes that
derive from a single abstract base class. I'm passing the base class
in, and I want to check the type, and cast it later. Please advise.
If you want to print out the name of the actual runtime dynamic type for
debugging purposes:

object->GetType()->Name

If you want to run some code depending on what type it is, use a virtual
function in the base class. If you absolutely can't change the base class,
use dynamic_cast<DerivedType^>(object), it will be a DerivedType^ or nullptr
depending on whether the object is really a DerivedType (or derived from
it).

Jun 21 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: George Sakkis | last post by:
Explicit type checking is not typically seen in Python code, and usually that's not a big problem; most typing errors are likely to raise a TypeError or AttributeError sooner than later. There are...
5
by: Tongu? Yumruk | last post by:
I have a little proposal about type checking in python. I'll be glad if you read and comment on it. Sorry for my bad english (I'm not a native English speaker) A Little Stricter Typing in Python...
6
by: Web Developer | last post by:
Hi, I come across the term "type checking" very often in my readings on C++, and have never heard it in Java. Besides the simplistic answer that it checks the "type", what more does it mean? ...
0
by: Moshe Plotkin | last post by:
B"H If XMLSerializer does not store the Class info. then can it store info for an object thats been casted down a level? i.e. class Address { public string street;
7
by: Busin | last post by:
In the code below, should i be casted to "unsigned int" type first before passing it into f()? Thanks! void f(unsigned int); int main() { unsigned short i; i = 23; /* Should i be casted to...
2
by: Timo Qvist | last post by:
Hi, I know there is a proper way to do this but I find myself with a void pointer returned from a malloc( sizeof( class T ) ) which gives me a pointer to a memory area of the size of class T. The...
9
by: Alexander Widera | last post by:
hi, is it possible to return an object of an unknown (but not really unknown) type with an method? i have the following situation: - a variable (A) of the type "object" which contains the...
11
by: Dinsdale | last post by:
I am trying to determine what the current cast of an object is. Essentially, if I use GetType, it always returns the original type of the object created but I want to know what the current cast of...
1
by: =?Utf-8?B?U2NvdHQ=?= | last post by:
Hello, Using VS2008 in a C# web service application, a class has been created that inherits from the ConfigurationSelection. This class file has been placed in the App_Code folder. The...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.