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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T03:03:47+00:00 2026-06-06T03:03:47+00:00

EDIT : the code has been trimmed down to contain only what is necessary

  • 0

EDIT: the code has been trimmed down to contain only what is necessary to reproduce the error. The error occurs at const V * Resolve(const Resource<T> *); and is error C2923: 'Resource' : 'T' is not a valid template type argument for parameter 'T'.

I’m using MSVC++ 2010 Express to compile the code displayed at the end of this post and I get these errors:

1>test.cpp(119): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>          test.cpp(121) : see reference to class template instantiation 'Resource<T>::Api<U>::ContainerDerived<V>' being compiled
1>          test.cpp(136) : see reference to class template instantiation 'Resource<T>::Api<U>' being compiled
1>          test.cpp(143) : see reference to class template instantiation 'Resource<T>' being compiled
1>test.cpp(119): error C2143: syntax error : missing ',' before '&'
1>test.cpp(120): error C2923: 'Resource' : 'T' is not a valid template type argument for parameter 'T'

(line 119 in the code is this: std::auto_ptr<Dependent<V> > Construct(const T &);)

It seems that the forward declaration template <typename V> class ContainerDerived; causes the definition of ContainerDerived to lose ‘visibility’ of the T parameter in the ancestor class Resource<T>.

Here is what I’ve tried:

  • Switch the definition order of Dependent<V> and ContainerDerived<V> (so the latter appears first), and change the forward declaration to template <typename V> class Dependent;. This fixes ContainerDerived but causes the same issue with Dependent.
  • Add typedef T FooBar; prior to either definition and switch all instances of ‘T’ to ‘FooBar’ in either/both of Dependent/ContainerDerived. This compiles, but the intended specialization when ‘T’ and ‘V’ are the same type does not occur.

Basically, it seems like adding a forward declaration of something is obscuring the T parameter from its definition. Anyone have any idea why this occurs?

Here is the code:

#include <memory>

template <typename TypeContainer, typename TypeContained>
class Proxy
{
public:
    class Container {};

    Proxy(TypeContainer * = NULL);
    Proxy(Proxy &);
    ~Proxy();
};

struct Dummy {};

template <typename T>
class Resource : public T, public Proxy<Resource<T>, Dummy>::Container
{
public:

    template <typename U>
    class Api
    {
    public:

        template <typename V> class ContainerDerived;

        template <typename V>
        class Dependent : public Proxy<ContainerDerived<V>, Dependent<V> > {};

        template <typename V>
        class ContainerDerived
        {
        public:
            const V * Resolve(const Resource<T> *);
        };

    };
};
  • 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-06T03:03:49+00:00Added an answer on June 6, 2026 at 3:03 am

    Quite a bit of complexity in these relationships. Of the main issues, you must use typename preceding dependant names.

    template <typename V>
    class ContainerDerived : public ContainerBase<ContainerDerived<V>, Dependent<V> >
    {
    public:
            typedef typename Api::Dependant<V> DV;
            typedef typename Resource::T TX;
        std::auto_ptr<DV> Construct(const TX &);
            typedef Resource<typename Resource::T> TR;
        const V * Resolve(const TR *);
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

EDIT: Removed code/explanation because this project has been given again and students can easily
EDIT: The code below has been edited to show the correct solution to the
EDIT: the code below has been fixed to receive and send properly AND to
Edit: The code below has been modified to work as the problem has been
EDIT: This code now works correctly, I only left it in case someone finds
I am getting a StackOverflow Error in this code: EDIT [XmlAttribute(ID)] public string ID
I am currently working with a piece of code that has been written by
My java code has been commented using /** structure for each function. So i
EDIT - The code looks strange here, so I suggest viewing the files directly
Edit: Added code (Exception on line 095, 5th time it's hit.) public DataTable ParseBarcodes(String[]

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.