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 6476915
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:53:03+00:00 2026-05-25T06:53:03+00:00

Simply put, what are the (or are there any) differences between doing say class

  • 0

Simply put, what are the (or are there any) differences between doing say

class MyClassList : list<MyClass> { };

vs

typedef list<MyClass> MyClassList;

The only advantage that I can think of (and its what lead me to this question) is that with the derived class i can now easily forward declare MyClassList as

class MyClassList;

without compiler error, instead of

class MyClass;
typedef list<MyClass> MyClassList;

I can’t think of any differences, but this made me wonder, are there cases in which a typedef can be used that a simple derived class can’t?

Or to put it another way, is there any reason why I shouldn’t change all my typedef list<…> SomeClassList; to the simple derived class so that I can easily forward declare them?

  • 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-25T06:53:04+00:00Added an answer on May 25, 2026 at 6:53 am

    Well, a typedef can only do what its name suggests while a derived class can possibly be a full-blown makeover of its base(s). So while there may not be much of a difference if you limit yourself to “just” deriving (and not add any members, or override anything, etc) as far as the compiler is concerned, there might be a big difference as far as human readers of the code are concerned.

    One might wonder “why is this a derived class when a typedef would suffice”? Most people would assume that there must be a reason, so you would make life harder to the code’s future maintainers. A typedef, on the other hand, is a very specific tool and does not raise questions.

    And while we ‘re on the topic of maintenance don’t forget that as most things in C++, this “nothing will go wrong as long as we are disciplined and don’t cross this line” is an open invitation to disaster. Since the compiler isn’t there to stop you, someone, someday, will cross the line.

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

Sidebar

Related Questions

Simply put! there is this list say LST = [[12,1],[23,2],[16,3],[12,4],[14,5]] and i want to
Is there any available C++ (or maybe C) function/class/library with only purpose to sanitize
Simply put: Is there any way to create non-modal JFace dialog? I've tried calling
Simply put, is there a way to create a 2D javascript array using similar
Simply put: What is the most effective way to share / reuse code between
doing this in AppDelegate: viewController = [[RootViewController alloc] initWithNibName:nil bundle:nil]; Is there any problem
Is there any way to emulate the list data structure in C? (What I
is there any way to programatically remove all microsoft html formatting that gets put
To put it simple, there's a simple java swing app that consists of JFrame
To put it simple: a swing app that uses sqlitejdbc as backend. Currently, there's

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.