Thread: Template and Inheritance

  1. #1

    Template and Inheritance

    Hi everyone
    I have major problems with my code and need help with the way I am writing my template inheritance class for LinkList (base class) and Stack (inheriting LinkList) and Queue(inheriting LinkList) I am getting a complier error in both Stack class and Queue class that I don't what it means
    What does this error mean ?
    " ambiguous call to overloaded function while compiling class-template member function"
    This error is on the constructor of the Queue class (same error for Stack too )

    Any one has references for template inheritance ? I am lost in the syntax codes.


  2. #2
    Somewhere your compiler can't resolve which function to call. This will happen if you have two methods like this:

    int func(int a, int b = 0);
    int func(int c);

    if you where to call func(5) for example, you will get this error.

  3. #3
    Join Date
    Aug 2001
    c++ has complicated rules for resolving overloaded functions
    such as

    void f(int n);
    void f(double n);


  4. #4
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    >This error is on the constructor of the Queue class (same error for Stack too )
    Could you post some code? It's just a tad easier to find the problem when we have source to look at.

    My best code is written with the delete key.

  5. #5
    here is the code:::

    class List
    struct LinkListElement{
    int key;
    int payLoad;
    LinkListElement *p;
    int length;
    LinkListElement *head;

    List(int size = 20)
    head = new LinkListElement;
    length = size > 0 ? size: 20;
    head->key = 0;
    head-> payLoad = NULL;
    // some other pop and push stuff

    ----------- Definition for Stack----------
    class Stack : private List
    int top;

    Stack() { } // apparantly this is a problem, because when i try to
    // instantiate the object of class Stack, I get errors

    // some other junk here

    -thanks alog

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 5
    Last Post: 04-15-2009, 02:47 PM
  2. Inheritance + Template
    By audinue in forum C++ Programming
    Replies: 5
    Last Post: 07-20-2008, 12:51 AM
  3. Need Help Please
    By YouShallNotPass in forum C++ Programming
    Replies: 3
    Last Post: 08-22-2006, 11:22 AM
  4. Questions about Templates
    By Shamino in forum C++ Programming
    Replies: 4
    Last Post: 12-18-2005, 12:22 AM