class professor {};

class teacher : public virtual professor {};
class researcher : public virtual professor {};
class myprofessor : public teacher, public researcher {};

Referring to the sample code above, if an object of class "myprofessor" were created, how many instances of professor will it contain?

Thank you for using the Jiskha Homework Help Forum, BUT why is this posting labeled "C++?" Sorry, but I do not understand what the sample code has to do with anything? A teacher teaches students but a researcher only does research and does not instruct students. A professor, especially at the university level, usually has an associate teaching the class. Can you clarify exactly what you need?

SraJMcGin this appears to be a C++ programming question, but I'm far to rusty to answer it.

Thank you for using the Jiskha Homework Help Forum. Aha! Thank you, Dr. Here are then some sites that may help:

1. http://www.cprogramming.com/

2. http://cplus.about.com/

only 1 instance of professor will it contain.

To answer the question, let's analyze the class hierarchy:

- The class "myprofessor" is derived from both "teacher" and "researcher" classes.
- The "teacher" class is derived from the "professor" class.
- The "researcher" class is also derived from the "professor" class.

Since both "teacher" and "researcher" are derived from the "professor" class, they will each contain an instance of the "professor" class.

When "myprofessor" is created, it will have two instances of the "professor" class - one from the "teacher" base class and one from the "researcher" base class. This is because both base classes virtually inherit from the "professor" class. Using virtual inheritance avoids having duplicate instances of the base class.

Hence, an object of the "myprofessor" class will contain only one instance of the "professor" class.