   determining the class from an ancestor
  I want to ask as a question.I have a function func:int func (classA c1);classA is the ancestor or classB and classChow can I determine if c1 is a classB or classC in function func? 
  you could pass it as a pointer, and use virtual member functions... then you don't need to know, the computer takes care of it for you.   [edited by - krez on February 4, 2004 9:28:14 PM];  no no no... classA, classB and classC has different functions. It could be a pointer also. I need to know if an address is the beginning address of a classA or B or C? I need to know which type it is.In delphi I could do it by using "is" keyword.if c1 is classB then begin ... end;How can I do this in VC++?;  typeid. ;  Short answer: You can use typeid() to compare dynamic types at runtime.Long answer: If you need to call different functions of the different classes (i.e. differently named functions, not merely overloads or overrides of base class functions), it seems to me that you might as well overload the function on the derived classes. If, on the other hand, the functions are merely overloaded or overriden versions of base class functions, you don''t want to call different code; just make them virtual functions and take a base class pointer or reference. In either case, I see no need for RTTI unless your situation is very particular. ;  The way you have the function prototype declared you can''t. What will happen is a classA object will be passed by value, potentially slicing the object. In this case you need   to pass the object by pointer or reference. Assuming we change the function prototype to int func(classA * c1);, you can do code something like:int func(classA * c1) {  if (classB * p = dynamic_cast<classB *>(c1)) {    // do stuff with the classB *  } else if (classC * p = dynamic_cast<classC *>(c1)) {    // do stuff with the classC *  }}  However, this is widely considered to be bad style. A better approach would be to refactor func() as a virtual member function of classA. Then overrides in classB and classC should be done that will perform the correct processing. ;quote:Original post by SiCrane  a classA object will be passed by value, potentially slicing the object.This is a somewhat odd bit of terminology, so here''s a description of the problem.