Thread: stack trouble

  1. #1
    Registered User
    Join Date
    Sep 2002
    Posts
    64

    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
    Location
    Göteborg, Sweden
    Posts
    2,072
    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
    Posts
    362
    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.

    -Skipper
    "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
    Posts
    64
    thanks so much guys, you took my headaches away!

    Enjoy!

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