Advertisement

11.13.2005 at 12:20PM PST, ID: 21629289
[x]
Attachment Details

Dynamic type casting?

Asked by dankennedy in C++ Programming Language

Tags: dynamic, type, casting

Is it possible to dynamically type cast a pointer to some object type?

I want a function something like this...

int ReturnSomething(LPVOID myPointer, SOME_TYPE_HERE) {
  int intReturn;
  intReturn = ((SOME_TYPE_HERE *)myPointer)->Something;
  return(intReturn);
}

The SOME_TYPE_HERE part should be dynamic so that I can pass in one or more types. All the types will be structures and will contain a "Something" element.  I have seen things mentioned about dynamic type casting, but I don't know if that's what I want to solve this problem.

Thanks for your help.Start Free Trial
 
Loading Advertisement...
 
[+][-]11.13.2005 at 01:08PM PST, ID: 15284443

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.13.2005 at 01:13PM PST, ID: 15284461

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.13.2005 at 01:37PM PST, ID: 15284534

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.13.2005 at 01:41PM PST, ID: 15284554

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.13.2005 at 02:09PM PST, ID: 15284609

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: C++ Programming Language
Tags: dynamic, type, casting
Sign Up Now!
Solution Provided By: cwwkie
Participating Experts: 2
Solution Grade: A
 
 
[+][-]11.13.2005 at 02:38PM PST, ID: 15284707

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.13.2005 at 04:04PM PST, ID: 15284988

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32