Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3493982
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T11:57:03+00:00 2026-05-18T11:57:03+00:00

Alright so I’ve looked for documentation by googleing, however I haven’t found any that

  • 0

Alright so I’ve looked for documentation by googleing, however I haven’t found any that really describes what I’m looking to answer, so here I am asking you guys.

So I get inheritance, and how it works. What I’m having a problem with is sometimes I see a object originally defined as one type, and set to a different type, and I don’t understand exactly what’s happening. Here’s an example:

Say I have a class animal, and classes cat and dog which extend animal. Cat, animal and dog all have a method speak() which for cat prints “meow” and for dog prints “woof” and for animal “can’t speak”.

Alright so finally here’s my question. What exactly happens if a make a cat (c) and then run Animal a = c;? What happens if I run a.speak();? Which speak method is called? What exactly has happened when I change types like that? Will I ever have any real reason to use this?

As far as abstract methods go, my question is what exactly is the point of having them? In the examples I’ve seen they’ve been put in super classes and the classes under them define the exact behavior. By putting an abstract method in a super class is one requiring all the classes under it to implement it?

Thanks for all your help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T11:57:04+00:00Added an answer on May 18, 2026 at 11:57 am

    What exactly happens if a make a cat
    (c) and then run Animal a = c;? What
    happens if I run a.speak();? Which
    speak method is called? What exactly
    has happened when I change types like
    that? Will I ever have any real reason
    to use this?

    Always the method of the real class, for example in this case, the speak() method of the cat.

    As far as abstract methods go, my
    question is what exactly is the point
    of having them?

    They make sure that, for example, every animal has a method walk() that you can call on every animal. It’s a warranty that says “every Animal object has this method, you don’t have to care about it”.

    In the examples I’ve
    seen they’ve been put in super classes
    and the classes under them define the
    exact behavior. By putting an abstract
    method in a super class is one
    requiring all the classes under it to
    implement it?

    To implement it or to be abstract, too, yes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Alright, so I've looked around the web and haven't been able to find what
Alright, here we go! I am currently developing an iPhone app that will work
Alright, I found out in this question that polling sockets does not scale, so
Alright, so here is what I'm hoping for... Any request to this http://www.fileorchard.com/3451928347592 will
alright, I'm trying something which should be like really easy. Here it is: usort($newarr,
Alright, this is basic c++ here. I've got a class that is a Linear
Alright, hard to phrase an exact title for this question, but here goes... I
Alright, I have a really basic QStandardItemModel , filled with some numbers. I managed
Alright so this is a bizarre cross platform thing that I'm experiencing with text
Alright y'all. I am attempting to write a bit of code that places typographic

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.