Thread: stack trouble

  1. #1
    Registered User
    Join Date
    Sep 2002

    stack trouble

    here is what I have and it is giving me errors:

    struct student_info
    int time;
    string last_name;
    string first_name;
    int course_number;
    int college_number;
    };//end struct composition

    stack<student_info> coordinator_in;
    student_info student;

    when i try to use it, it gives me this error:
    'struct main::student_info' : types with no linkage cannot be used as template arguments

    when i change the stack to something like stack<int> i have no plroblems. i have included stack as well.

    any suggestions?

  2. #2
    S Sang-drax's Avatar
    Join Date
    May 2002
    Göteborg, Sweden
    Declare the struct in a global scope (not inside main() or any other function).

    If it already is, buy/download a new compiler.
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  3. #3
    Registered User
    Join Date
    Apr 2002
    Sang-drax is exactly on the money.

    Borland puts out a slightly more descriptive error message.

    "Template argument cannot have static or local linkage."

    Declaring the struct in the global scope takes care of the problem. (I tried it. )

    Nice call, Sang-drax.

    "When the only tool you own is a hammer, every problem begins to resemble a nail." Abraham Maslow

  4. #4
    Registered User
    Join Date
    Sep 2002
    thanks so much guys, you took my headaches away!


Popular pages Recent additions subscribe to a feed

Similar Threads

  1. stack and pointer problem
    By ramaadhitia in forum C Programming
    Replies: 2
    Last Post: 09-11-2006, 11:41 PM
  2. infix evaluation using stack
    By lewissi in forum C++ Programming
    Replies: 0
    Last Post: 11-03-2005, 02:56 AM
  3. Question about a stack using array of pointers
    By Ricochet in forum C++ Programming
    Replies: 6
    Last Post: 11-17-2003, 10:12 PM
  4. error trying to compile stack program
    By KristTlove in forum C++ Programming
    Replies: 2
    Last Post: 11-03-2003, 06:27 PM
  5. Stack Program Here
    By Troll_King in forum C Programming
    Replies: 7
    Last Post: 10-15-2001, 05:36 PM