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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:39:07+00:00 2026-05-13T20:39:07+00:00

Try this out: template <typename T> class Base { public: int someBaseMember; }; template

  • 0

Try this out:

    template <typename T>
    class Base
        {
        public:
            int someBaseMember;
        };

    template <typename T>
    class Test: public Base<T>
    {
    public:
        void testFunc()
        {
            someBaseMember = 0;
        }
    };

In vc++ and the psp compiler (and any other compiler I’ve encountered) the above will work fine, with the iphone compiler (for device, gcc 4.2 I think, with the -fpermissive flag set) I get an error saying
‘someBaseMember is not defined’
on the
‘someBaseMember = 0;’
line

The iphone compiler seems to be ‘parsing’ templated code a lot sooner than other compilers do, (from what I can tell, most others don’t even syntax check them until you actually CALL the function, or instantiate an instance.)

From what I can tell its parsing it so soon that it hasn’t even parsed the base class yet :S its like it doesn’t exist.

Any Ideas?

  • 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-13T20:39:08+00:00Added an answer on May 13, 2026 at 8:39 pm

    The error that you are getting is correct (the other compilers should not accept the code and are doing so erroneously); the variable someBaseMember depends on the template instantation of Base<T>, but this dependence has not been expressed in your usage, and hence the compiler is correct in attempting to resolve it independently of the template parameter.

    You can resolve this problem by making this dependence explicit, thereby forcing the compiler to resolve the variable using the template instantation. You can use either of the following:


    this->someBaseMember = 0;

    OR


    Base<T>::someBaseMember = 0;

    Either of the above should result in the resolution mechanism you want.

    EDIT
    You might want to see the relevant section of the C++ FAQ Lite:
    http://www.parashift.com/c++-faq-lite/templates.html#faq-35.19
    http://www.parashift.com/c++-faq-lite/templates.html#faq-35.18

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

Sidebar

Related Questions

Try this code - import java.io.StringReader; public class StringReaderTest { public static void main(String[]
Try this piece of code - public class WhitespaceTest { public static void main(String[]
I am working on a CMS template and try to find out if this
I get this, when I try to run my PHP. When I comment out
I try this with NetBeans desktop application template - increasing heapsize (to 512 MiB)
I found this vector template class implementation, but it doesn't compile on XCode. Header
I've been searching for hours to try and figure this out, and it seems
I have a subset of a pointer class that look like: template <typename T>
I try this command : Rscript /Users/test/Scripts/arg_test.R path_in=/Users/test/GR/web-app/Rproject/Inputs/Rmerge/Description.csv path_in2=/Users/test/IdeaProjects/Rproject/Inputs/Rmerge/Template_Auto.csv but I have this error
I'm building a small template hierarchy and try to make use of class polymorphism.

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.