Thread: Simple issue but I am STUCK

  1. #1
    Registered User
    Join Date
    Aug 2006
    Posts
    10

    Simple issue but I am STUCK

    O.k. this is so simple that it's embarrassing. I just can't seem to get it right. O.k. here's the basic stuff first:

    • This is part of a class assignment, but this in itself is not THE assignment
    • I'm not in any way asking for a cheat. The template function is already done and ready to hand in.
    • The assignment involves the prototype and implementation of template functions
    • Compiler = Visual C++ 6.0


    O.k. so here's the issue. I can't seem to figure out how to properly call a template function in the main function. I know that this ought to be something simple, but @#$% if I'm not pulling out my hair trying to make it work. Here's a sample of my code:
    Code:
    #include <iostream>
    #include <queue>
    
    
    using namespace std;
    
    template <typename T>
    void n2front(queue<T>& q, int n);
    
    int main()
    {
    
    	n2front();  //Here is where I just can't seem to call the template function correctly
    
    	return(0);
    }
    
    template <typename T>
    void n2front(queue<T>& q, int n)
    {
    
    	// Perform the needed function operation for the assignment
    
    }
    All that I'm trying to do is simply call the template function n2front. I'm going crazy on this mostly because I know it ought to be simple. I am sure I am simply overlooking something.

    Any helpful comments are greatly appreciated.

    Thanks.

  2. #2
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    Code:
    	queue<int> myQueue;
    
    	n2front(myQueue,10); //Here is where I just can't seem to call the template function correctly
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  3. #3
    Registered User
    Join Date
    Aug 2006
    Posts
    10
    Bingo. That did it. See I knew it was something simple like that. Thanks for the help.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 1
    Last Post: 12-30-2007, 10:08 AM
  2. Very Simple C Program
    By jennydarma in forum C Programming
    Replies: 4
    Last Post: 11-01-2002, 08:16 PM
  3. ...deceptively simple...
    By Sebastiani in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 07-29-2002, 12:51 PM
  4. Need help with simple DAQ program
    By canada-paul in forum C++ Programming
    Replies: 12
    Last Post: 03-15-2002, 08:52 AM
  5. Simple Compile Time Problem - HELP!
    By kamikazeecows in forum Windows Programming
    Replies: 2
    Last Post: 12-02-2001, 01:30 PM