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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T10:40:09+00:00 2026-06-18T10:40:09+00:00

Here, I test to check a var defined by typename D, is a unqualified

  • 0

Here, I test to check a var defined by “typename D”, is a unqualified
dependant name. The answer is YES. since if i write its definition twice:

template<typename D>
class A { 
   D d_field;
   D d_field;

   void func() { d_field = 1000; } 
 }

 int main()
 {
    return 0;
 }

the g++ will report re-definition error. so that it demonstrates “d_field” is checked in template definition.

and if I give a type “double*” to use this template. The template instantiation happens, with an error reported in func2, “int can’t be converted to double*”.

template<typename D>
class A { 
   D d_field;

   void func() { d_field = 1000; } 
 }

 int main()
 {
    A<double*> a; 
    a.func(); 
    return 0;
 }

it prove that “d_field” will be check in template instantiation.

In addition, I change that as below, the g++ will compile it ok.It prove that gcc works in two-phase-lookup based on c++ standard… if the name is qualified dependant name, it will only be checked in template instantiation.

template<typename D>
class A { 
   D:: d_field;
   D:: d_field;

   void func() { d_field = 1000; } 
 }

 int main()
 {
    return 0;
 }

In a word, use a template parameter to define a variable in template, the variable’s name is a unqualified dependant name.

is it right?

  • 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-18T10:40:11+00:00Added an answer on June 18, 2026 at 10:40 am

    No. The variable’s name is a locally declared name, so it is neither dependent nor non-dependent. Only names which the compiler has to look up outside of the template can be dependent or non-dependent.

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

Sidebar

Related Questions

I have two arrays: $array1 = array(1=>1,10=>1,12=>0,13=>13); $array2 = array(1=>Hello,10=>Test,12=>check,13=>error); Here $array1 has keys
Here's a method I need to unit test: void Do(IEnumerable<string> items, TextWriter tw){ foreach(var
When I write a test in Visual Studio, I check that it works by
I created a login page using spring_security_check. Here: <form name='f' action=/sec_test/j_spring_security_check method='POST'> <table> <tr>
I often hear around here from test driven development people that having a function
Here's my test: @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { classpath:repositoryContextTest.xml }) @Transactional @TransactionConfiguration(defaultRollback = true) public
Here is my test code: <script type=text/javascript> YUI({ modules: { 'jquery': { fullpath: 'script/lib/jquery.min.js'
Here is a test description, testing the Create New Widget use-case. Confirm that you
here is the test page http://www.studioteknik.com/html/test-portfolio.html I got no error, but no hover-slide effect...
Here is a test framework to show what I am doing: create a new

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.