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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:53:32+00:00 2026-06-12T15:53:32+00:00

I have the following class setup that trys mimicks a very basic stack. template

  • 0

I have the following class setup that trys mimicks a very basic stack.

template <class T>
class Stack{
    public:
        static const unsigned MAX_STACK_DEPTH =4;
        Stack();
        unsigned elements() const;
        Stack<T> & push(T &value);
        T pop();
        Stack<T> & show();
    private:
        unsigned element;
        T stack[MAX_STACK_DEPTH];
};

template <class T>
Stack<T>::Stack(){
    element=0;
}
/*Other class function definitions*/

My problem is that I’m getting the following error in main

1   IntelliSense: no instance of function template "calc" matches the argument list c:\users\nima\documents\visual studio 2010\projects\calcu\calcu\policalc.cpp    109 6   Calcu

Here is my main

int main(){
    bool run=true;
    while(run){
        if(calc(input()));
    }
}

here are the other two functions declarations

string input();
template <class T>
bool calc(string line);

Here is my calc function, It’s not finished.

template <class T>
bool calc(string line){
    static T Ans;
    istringstream sin(line);
    Stack stack;
    for(string token; sin>>token){
        T t;
        if(parse(t, token)){
            push(t);
        }else{
            if(token==operators[i]){
                switch(i){
                case 1:{

                       }
                }
            }
        }
    }
}
  • 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-12T15:53:34+00:00Added an answer on June 12, 2026 at 3:53 pm

    Your calc function is a function template with parameter T, but that parameter isn’t used by any of the function arguments – the only argument is defined as a string, regardless of what type T is.

    Therefore, the compiler cannot defer T when you call calc like this:

    calc(input())
    

    You need to explicitly specify T, e.g.:

    calc<int>(input())
    

    (Of course, you should use whatever data type makes sense instead of int.)

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

Sidebar

Related Questions

I have the following setup. Class, say, Car that has a CarPart (belongsTo=[car:Car]). When
I'd like to have the following setup: class Descriptor { public string Name {
I have the following setup: A templated class SpecialModel: template<typename A, typename B> class
I have following setup. method and method1 both are public methods of class Student.
I have the following class: public abstract class AbstractParent { static String method() {
I have the following setup, abridged for brevity: public abstract class AuditableEntity { public
i have the following models setup class Player(models.Model): #slug = models.slugField(max_length=200) Player_Name = models.CharField(max_length=100)
If I have the following has_one setup: class Account has_one :user How can I
I have following models setup in my Django application class School(models.Model): name = models.TextField()
I have following class public class ButtonChange { private int _buttonState; public void SetButtonState(int

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.