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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:33:43+00:00 2026-05-24T20:33:43+00:00

Can I use forward declaration for template class? I try: template<class que_type> class que;

  • 0

Can I use forward declaration for template class?
I try:

template<class que_type>
class que;
int main(){
    que<int> mydeque;
    return 0;
}
template<class que_type>
class que {};

I get:

error: aggregate 'que<int> mydeque' has incomplete type and cannot be defined.
  • 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-24T20:33:44+00:00Added an answer on May 24, 2026 at 8:33 pm

    Forward declaration of a class should have complete arguments list specified. This would enable the compiler to know it’s type.

    When a type is forward declared, all the compiler knows about the type is that it exists; it knows nothing about its size, members, or methods and hence it is called an Incomplete type. Therefore, you cannot use the type to declare a member, or a base class, since the compiler would need to know the layout of the type.

    You can:

    1. Declare a member pointer or a reference to the incomplete type.
    2. Declare functions or methods which accepts/return incomplete types.
    3. Define functions or methods which accepts/return pointers/references to the incomplete type.

    Note that, In all the above cases, the compiler does not need to know the exact layout of the type & hence compilation can be passed.

    Example of 1:

    class YourClass;
    class MyClass 
    {
        YourClass *IncompletePtr;
        YourClass &IncompleteRef;
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my C++ header files I try to use forward declarations (class MyClass;) instead
Do you know if I can use Visio to forward-engineer a sequence diagram into
How can I use .htaccess to forward a visitor of a specific IP address
Is there a pure-Java equivalent to <jsp:forward page=... /> that I can use within
You can use more than one css class in an HTML tag in current
You can use SelectFolder() to get a folder or GetOpenFolderitem(filter as string) to get
I can use VS08's MFC/ActiveX template to create a C++ ActiveX object that I
When trying to use an auto_ptr with a type that was declared with forward-declaration,
I know that I can use .Min() to get minimum value from column, but
I know that I can do: class Foo; but can I forward declare 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.