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

  • Home
  • SEARCH
  • 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 672017
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:26:15+00:00 2026-05-14T00:26:15+00:00

It is mentioned in C++ FAQ site — larger derived class objects get sliced

  • 0

It is mentioned in C++ FAQ site — “larger derived class objects get sliced when passed by value as a base class object”, what does slicing mean? Any sample to demonstrate?

http://www.parashift.com/c++-faq-lite/value-vs-ref-semantics.html#faq-31.8

I am using VSTS 2008 + native C++ as my development environment.

  • 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-14T00:26:16+00:00Added an answer on May 14, 2026 at 12:26 am

    Quoting this lecture:

    Slicing

    Suppose that class D is derived from
    class C. We can think of D as class C
    with some extra data and methods. In
    terms of data, D has all the data that
    C has, and possible more. In terms of
    methods, D cannot hide any methods of
    C, and may have additional methods. In
    terms of existing methods of C, the
    only thing that D can do is to
    override them with its own versions.

    If x is an object of class D, then we
    can slice x with respect to C, by
    throwing away all of the extensions
    that made x a D, and keeping only the
    C part. The result of the slicing is
    always an object of class C.

    slicing http://webdocs.cs.ualberta.ca/~hoover/Courses/201/201-New-Notes/lectures/slides/slice/slide1.gif

    Design Principle: Slicing an object
    with respect to a parent class C
    should still produce a well-formed
    object of class C.

    Usage Warning: Even though D is-a C,
    you must be careful. If you have a
    argument type that is a C and you
    supply a D it will be sliced if you
    are doing call by value, pointer, or
    reference. See the example below.

    Note on virtual functions. Their
    signatures are used to identify which
    one to execute.

    Watch out for the sliced = operator,
    it can make the lhs inconsistent.
    Also, the operator= is never virtual,
    it wouldn’t make sense. For example,
    suppose classes A, B are both
    subclasses of class C. Just because an
    A is a C, and a B is a C, it doesn’t
    mean you can assign a B object to an A
    object. Without run-time type
    information you cannot make a safe
    assignment.

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

Sidebar

Ask A Question

Stats

  • Questions 355k
  • Answers 355k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Just parse using Linq-To-XML. Something like: (from a in b… May 14, 2026 at 8:34 am
  • Editorial Team
    Editorial Team added an answer app_offline.htm works on MVC sites. You need to make sure… May 14, 2026 at 8:34 am
  • Editorial Team
    Editorial Team added an answer I think you mean this: for(var x=0;x<thearray.length;x++) { document.write '<a… May 14, 2026 at 8:34 am

Related Questions

tl;dr: Is there a non-short circuit logical AND in C++ (similar to &&)? I've
I have worked on projects for embedded systems in the past where we have
I've recently come across this rant . I don't quite understand a few of
I am having trouble getting my project to link to the Boost (version 1.37.0)
Some background: As a personal project, I've been developing a kernel in c++. Things

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.