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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:40:32+00:00 2026-06-17T09:40:32+00:00

Possible Duplicate: Two phase lookup – explanation needed When I’m using a template class

  • 0

Possible Duplicate:
Two phase lookup – explanation needed

When I’m using a template class the compiler doesn’t show me errors/warning of missing #includes.

For example, If I have a class called “A” and it looks much or less like this :

template<class T>
class A {
    void print() const {cout << "Hey I didn't use include for 
                                 iostream and It works just fine!!!";}
};

If I remove the template < class T > I get errors of the absence of <iostream >include.

Why the compiler doesn’t show these errors when I’m using template class ?

Just to point out, when I say It works I mean It doesn’t show me any compilation errors when I’m writing the class but only when I use it as opposed to a non-template class whereas the error shows immediately.

  • 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-17T09:40:33+00:00Added an answer on June 17, 2026 at 9:40 am

    When you write template code, a huge bulk of the syntax checking happens only if and when you make an instance of this class, if it is never used, it is never checked.

    To verify this, add this line at the end, A<int>;

    More information at Two phase lookup – explanation needed as jrok points out.

    Edit:

    The linked posts bring up an interesting point, this does error out on gcc and clang even without an instantiation. I guess like myself, you are on MSVC++

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

Sidebar

Related Questions

Possible Duplicate: Two css files defining same class The answers to this question and
Possible Duplicate: Comparing Two Arrays Using Perl I am trying to find elements that
Possible Duplicate: Passing two command parameters using a WPF binding I need that send
Possible Duplicate: comparing contents of two files using python I have a file name
Possible Duplicate: Getting Using two-stage rotation animation warning with UIImagePickerController In my iphone app
Possible Duplicate: Swapping two variable value without using 3rd variable we have int a=4;
Possible Duplicate: Implement Stack using Two Queues I want the most efficient way in
Possible Duplicate: Comparing Two Arrays Using Perl How can I print values which exist
Possible Duplicate: Concatenate Two NSDate String values Just confused that is there any default
Possible Duplicate: Concatenating two QStrings with an integer i'm looking forward to create a

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.