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

  • Home
  • SEARCH
  • 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 6596479
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:04:54+00:00 2026-05-25T18:04:54+00:00

In my FileProc class, I have four functions: ReadFile(TemplateList<char> &ReadList){} ReadFile(TemplateListAdv<char> &ReadList){} ReadFile(CharList &ReadList){}

  • 0

In my FileProc class, I have four functions:

ReadFile(TemplateList<char> &ReadList){}
ReadFile(TemplateListAdv<char> &ReadList){}
ReadFile(CharList &ReadList){}
ReadFile(CharListAdv &ReadList){}

Which are all supposed to call a centralised method (which they are converted to):

ReadFile(TemplateListEditor<char> &ReadList){} //Contained by FileBasic

For background information, class hierarchy is as follows:

TemplateList -> CharList
TemplateList -> TemplateListAdv
CharList -> CharListAdv
TemplateList -> TemplateListEditor
FileBasic -> FileProc

My issue is there is a recursive function call (where TemplateList converted into TemplateListEditor will keep calling the TemplateList function), despite the fact the classes are internally different. Typecasting does not seem to work. Without renaming the function (which would defeat the point as it’s supposed to be universal), how do I make the method look up the correct method?

(And I am surprised the compiler never flagged up an ambiguity resolution error for this).

Example:

const bool ReadFile(TL::TemplateList<char> &ReadList, const bool Recursion = false)
{
    printf("Is recursion true? %d!\n",Recursion);
    TL::TemplateListEditor<char> Temp(ReadList);

    //Calls itself instead of
    //const bool ReadFile(TL::TemplateListEditor<char> &ReadList, const bool Recursion = false)
    if(!ReadFile(static_cast<TL::TemplateListEditor<char> &>(Temp),true ))
    {
        return false;
    }
    return true;
}

The above will ouput:

Is recursion true? 0
Is recursion true? 1
Is recursion true? 1
etc

It strikes me TemplateListEditor (despite being static cast etc etc) is somehow or for some mind boggling reason, being converted back to TemplateList. Editor’s constructors are all explicit.

  • 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-25T18:04:55+00:00Added an answer on May 25, 2026 at 6:04 pm

    Your question isn’t very clear. But I’m assuming you have something like this:

    class A { ... };
    class B : public A { ... };
    
    void readFile(A &a) { ... };
    
    void readFile(B &b)
    {
        readFile(b); // Recursive call
        readFile(static_cast<A&>(b));  // Non-recursive call
    }
    

    Function overloads are determined at compile-time, not run-time. The compiler attempts to locate the best match based on the static types of the arguments.

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

Sidebar

Related Questions

I have a class called FileProc that runs File IO operations. In one instance
In my program I have code like the following /* libname may be a
I'm studying the code of the netstat tool (Linux), which AFAIK mostly reads a
I try to read file /proc/'pid'/status, using c program. The code is as follows,
I am trying to understand my embedded linux memory usage. By using the top
We've run into a thorny problem. We are writing a c++ program that receives
Greetings, I am trying to play some audio files without holding up the GUI.
im reading the content of the file /proc/net/tcp6 and trying to transform that notation
I am trying to add some information to a python script that posts the
Before anyone jumps to conclusions as to the nature of this question, I already

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.