Question

Which of the following assignments would be an error without a cast? Assigning the address of...

Which of the following assignments would be an error without a cast?

Assigning the address of a base-class object to a base-class pointer.

Assigning the address of a derived-class object to a derived-class pointer.

Assigning the address of a base-class object to a derived-class pointer.

Assigning the address of a derived-class object to a base-class pointer.

0 0
Add a comment Improve this question Transcribed image text
Answer #1


C.  Assigning the address of a base-class object to a derived-class pointer.

Add a comment
Know the answer?
Add Answer to:
Which of the following assignments would be an error without a cast? Assigning the address of...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • (T/F) ______ A base class pointer/reference may contain the address of an object of the base...

    (T/F) ______ A base class pointer/reference may contain the address of an object of the base class or an object of classes derived from the base class.

  • 8. Virtual function is class function which expected to be redefined in class, so that when...

    8. Virtual function is class function which expected to be redefined in class, so that when reference is made to derived class object using pointer then we can call virtual function to execute class definition version. [3] a) Base, derived, derived b) Derived, Derived, Derived c) Base, derived, base d) Base, base, derived

  • A) Suppose you have a class called base which has been inherited by a class called...

    A) Suppose you have a class called base which has been inherited by a class called derived.     ( both classes have public, protected and private members )     What can a client of derived access within the class base ?     What can the class derived access within the class base ? B) Suppose you have a class called more which has a private object of a class called simple. ( both classes have public, protected and private members...

  • Suppose the base class and the derived class each have a member function with the same...

    Suppose the base class and the derived class each have a member function with the same signature. When you have a pointer to a base class object and call a function member through the pointer, discuss what determines which function is actually called—the base class member function or the derived-class function.

  • This is In C++ only Thank you 2. Employee is a base class and Hourly Worker...

    This is In C++ only Thank you 2. Employee is a base class and Hourly Worker is a derived class. Which statement about the destructors of both classes is true? al They should be declared virtual u Declaring them virtual or not does not make any difference c) They should be implemented as friend functions d) The destructor of HourlyWorker must be virtual whereas the destructor of Employee should 3. If a base class has a non-virtual member function called...

  • D Question9 Which of the following represents the output of the following code segment? abstract class...

    D Question9 Which of the following represents the output of the following code segment? abstract class Base Base0System.out.println("Base Constructor Called"); abstract void fun: class Derived extends Base Constructor Called"): fun) called"): ) class MainClass Derived0 System.out.println("Derived void fun [System.out.printin/"Derived public static void main(String args) Derived d = new Derived@; O Print "Derived Constructor Called then print Base Constructor Called O Print "Base Constructor Called then print Derived Constructor Called" O We must write @override above the fun) method in Derived...

  • URGENT! Consider the following code for the definition of a Home object: 1 This class also...

    URGENT! Consider the following code for the definition of a Home object: 1 This class also contains getters, setters and a _str_method for it's owner and address attributes. class Home: def __init__(self, owner, address) self_owner owner, sell_address address Create a (derived) Apartment class that inherits from the Home class, but also has an attribute called rental price. Implement the Apartment class to inherit from the base Home class and contains all appropriate methods that need to be written for this...

  • In Exercise 1, displayAnimal uses an Animal reference variable as its parameter. Change your code to...

    In Exercise 1, displayAnimal uses an Animal reference variable as its parameter. Change your code to make the displayAnimal function anim parameter as an object variable, not a reference variable. Run the code and examine the output. What has changed? Polymorphic behavior is not possible when an object is passed by value. Even though printClassName is declared virtual, static binding still takes place because anim is not a reference variable or a pointer. Alternatively we could have used an Animal...

  • I do not understand the output when using dog.print() Can you explain what happens when Dogtype...

    I do not understand the output when using dog.print() Can you explain what happens when Dogtype dog("Tommy", "German....."); and dog.print() executes. This is c++ For classes 1. Include the destruc 2. 3. Include the copy constructor. tor in lI Overload the assignment operator for the class r 13 discusses overloading the assignment operator. Until Chapte discuss classes with pointer member variables, out of the three iten we will implement only the destructor and the copy constructor. Inheritance, Pointers, and Virtual...

  • Question 1 2 pts The preprocessor executes after the compiler. False True Question 2 2 pts...

    Question 1 2 pts The preprocessor executes after the compiler. False True Question 2 2 pts What code is human-readable and follows the standards of a programming language? Secret code Source code Key code None of these Machine code Question 3 2 pts What is the symbol that marks the beginning of a one line comment? Question 1 2 pts The preprocessor executes after the compiler. True False Question 5 2 pts A statement that may be used to stop...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT