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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:08:35+00:00 2026-06-13T13:08:35+00:00

I can deal with porting platform dependent functions. I have a problem that the

  • 0

I can deal with porting platform dependent functions. I have a problem that the compilers I tried on Linux (clang and g++) do not accept the following code, while the msvc++ compiler does:

template <class T>
class Base {
protected:
    T Value;
};

template <class T>
class Derived : public Base<T> {
public:
    void setValue(const T& inValue){
        Value = inValue;
    }
};

int main(int argc, char const *argv[])
{
    Derived<int> tmp;
    tmp.setValue(0);
    return 0;
}

g++ error:

main.cpp: In member function ‘void Derived<T>::setValue(const T&)’:
main.cpp:11:3: error: ‘Value’ was not declared in this scope

I believe this due to the use of a non-dependent name (Value) in the second class. More information.

The problem is that I have a very large code base, in which this type of code is used very often. I understand that it is wrong when looking at the standard. However it is very convenient not having to write this-> or Base<T>:: in front of every use of Value. Even writing using Base<T>::Value; at the start of the derived class is problematic when you use ~20 members of the base class.

So my question is: are there compilers for Linux that allow this kind of code (with or without extra compiler switches)? Or are there small modifications that will allow this code to compile on Linux?

  • 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-13T13:08:36+00:00Added an answer on June 13, 2026 at 1:08 pm

    You have to say this->Value or Base<T>::Value, because Value is a dependent name. Alter­natively, add using Base<T>::Value; to your derived class definition. There’s no way around this.

    The Microsoft compiler was simply sub-standard, and it is your misfortune to have coded to a vendor’s style and not to the published C++ standard, I’m afraid.

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

Sidebar

Related Questions

I have a menu with submenus that can be toggled (hide/show type deal). Is
Does Scala have any sort of classes that can deal with this? I was
I have an interesting problem. I'd like to create a generic class that can
I have a restful web service which can deal with DTOs in json format
I would like to create a function that can deal with an object that
Is there a conversion utility from svn to hg that can deal with a
Can't how to deal with my problem: part of view are hidden, when page
Why Nibernate HQL can not handle the following query: from Deal D where (D.ApprovalDate
I have the unfortunate luck of having to deal with a db that contains
Which .NET JSON serializers can deal with NHibernate proxy objects? I tried using JSON.NET

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.