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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T04:36:23+00:00 2026-06-03T04:36:23+00:00

I am having some trouble passing parameters for a template function trough a non-template

  • 0

I am having some trouble passing parameters for a template function trough a non-template function.

Let’s supose I have this:

template <class T>
void A(Array <T> &A) {
    cout << "here";
}


void menu(Array<myType>& fooList) { // my type specified class type, created by me. 
    cout << "enter option ";
    cin >> a;

    switch {
       case 1: A(fooList); break;
    }
}

I hope the example is clear enough. Is this possible or not? Can I the parameters pass from a non-template function to a template function?

EDIT: – the actual code since the prototype i tried to build wasn’t helpful.

domain.h

template <class T>
void printAll(Array <T> &DBst, Array <T> &DBas){
    for(int i=0; i<DBst.lenght; i++){
        DBst.M[i].printStudent();
        std::cout<<" ___ ";
        DBas.M[i].printAssgn();
        std::cout<<std::endl;
    }
}

controller.h

template <class T>
void _printAll(Array <T> &DB1, Array <T> &DB2){
    cout<<"List of students with their Assignment!"<<endl;
    printAll(DB1, DB2);
    cout<<"done!"<<endl;
}

menu.cpp

void Menu::mainMenu(Array <Student> &DBst,Array <Assignment> &DBas){
showMainMenu();
int ret = Menu::intInputHandler();

while(ret){
    switch(ret){
    case 1:studentMenu(DBst,DBas);break;
    case 2:assignmentMenu(DBst,DBas);break;
    case 3:statsMenu(DBst,DBas);break;
    case 4:_printAll(DBst,DBas);break; //// ERROR ***
    case 0:/*exit*/;break;
    default:cout<<"Wrong option selected!";break;
    }
    }

    }

menu.h

class Menu{

public:
    void showMainMenu();
    void showStudentMenu();
    void showAssignmentMenu();
    void showStatisticsMenu();
    string stringInputHandler();
    int intInputHandler();
    void mainMenu(Array <Student> &,Array <Assignment> &);
    void studentMenu(Array <Student> &,Array <Assignment> &);
    void assignmentMenu(Array <Student> &,Array <Assignment> &);
    void statsMenu(Array <Student> &,Array <Assignment> &);

};

*..\Menu.cpp:90:29: error: no matching function for call to '_printAll(Array<Student>&, Array<Assignment>&)'

  • 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-03T04:36:24+00:00Added an answer on June 3, 2026 at 4:36 am

    Well your _printAll(DBst,DBas); are array of two different types; and _printAll can take only two arrays of same type. You need to define a function with

    template <class T1, class T2>
    void printAll(Array <T1> &DBst, Array <T2> &DBas) 
    

    and a corresponding _printAll

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

Sidebar

Related Questions

Im having some trouble writing a getstring function, this is what I have so
Having some trouble passing values from one class to another. I basically have a
having some trouble passing a function as a parameter of another function... ERROR: Error
I am having some trouble with the Ion_Auth forgotten password function. I have loaded
I'm having some trouble with JavaScript and the passing of a function as parameter
I am having some trouble with passing data of an array from one class
I'm having some trouble passing a number as an argument for a method: -
Im having some trouble with joining two tables. This is what my two tables
I'm having trouble passing a variable defined in one class instance to another class
Hi i am having some trouble passing variables/doing functions from other classes, Right now

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.