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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:32:18+00:00 2026-06-15T18:32:18+00:00

Say I have the following classes: template <class T> class Base { protected: T

  • 0

Say I have the following classes:

template <class T>
class Base {
  protected:
    T theT;
    // ...
};

class Derived : protected Base <int>, protected Base <float> {
  protected:
    // ...
    using theInt = Base<int>::theT;     // How do I accomplish this??
    using theFloat = Base<float>::theT; // How do I accomplish this??
};

In my derived class, I would like to refer to Base::theT using a more intuitive name that makes more sense in the Derived class. I am using GCC 4.7, which has pretty good coverage of C++ 11 features. Is there a way of using a using statement to accomplish this kind of how I tried in my example above? I know that in C++11, the using keyword can be used to alias types as well as eg. bring protected base class members into the public scope. Is there any similar mechanism for aliasing a member?

  • 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-06-15T18:32:19+00:00Added an answer on June 15, 2026 at 6:32 pm

    Xeo’s tip worked. If you are using C++ 11, you can declare the aliases like so:

    int   &theInt   = Base<int>::theT;
    float &theFloat = Base<float>::theT;
    

    If you don’t have C++11, I think you can also initialize them in the constructor:

    int   &theInt;
    float &theFloat;
    // ...
    Derived() : theInt(Base<int>::theT), theFloat(Base<float>::theT) {
      theInt = // some default
      theFloat = // some default
    }
    

    EDIT:
    The slight annoyance is that you can’t initialize the the value of those aliased members until the main body of the constructor (ie, inside the curly braces).

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

Sidebar

Related Questions

Lets say i have the following c# classes: abstract class a { protected abstract
Using Mongoid, let's say I have the following classes: class Map include Mongoid::Document embeds_many
Say we have the following two classes, A is the base class with virtual
Say I have the following POCO classes: public class AuditableModel { public int ID
Say I have the following POCO classes: public class Parent { public int ID
Let say I have the following classes, Public Class Base Public Event PropertyChanged() Sub
Say I have the following classes: public class A { public string x; }
Let's say I have the following classes set up: class Foo: def __init__(self, frob,
Say I have the following classes public class TestA { public string Blah {
Let's say I have the following classes : public class MyProductCode { private String

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.