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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T14:28:48+00:00 2026-05-12T14:28:48+00:00

Is the following valid? Or how can I get something close to this. template<class

  • 0

Is the following valid? Or how can I get something close to this.

template<class T_> class Template {
   //something
};

class Parent {
public:
   Template<Parent> variable;

   Parent() : variable(this) { }
};

class Derived : public Parent {
public:
   Template<Derived> variable;

   Derived() : Parent() { }
}

Thanks in advance.

  • 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-12T14:28:48+00:00Added an answer on May 12, 2026 at 2:28 pm

    It’s technically “valid” in that your compiler has to accept it (it may warn you, and IMHO it should), but it doesn’t do what you think it does: Derived’s variable is separate from Parent‘s, and is not getting explicitly initialized (so it uses the default ctor for Template<>).

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

Sidebar

Related Questions

With a vector defined as std::vector<std::string> , Wondering why the following is valid: if
In C the following horror is valid: myFunc() { return 42; // return type
With valid HTML the following finds the object as expected in all browsers but
Following this question: Good crash reporting library in c# Is there any library like
Following on from this question what would be the best way to write a
Following up on this question, I'm working on a large Delphi 7 codebase which
Ok say I have the following model: class Country < ActiveRecord::Base validates_presence_of :name validates_presence_of
I have following code: class EntityBase (object) : __entity__ = None def __init__ (self)
I am trying out some globalization in an asp.net mvc2 application but can't get
According to http://www.storytotell.org/blog/2008/11/14/literal-tables-and-updates-with-joins-in-sql.html the following is valid: SELECT * FROM VALUES ('Lisp', 50, true),

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.