Help with Unresolved External.

Discussion in 'C++' started by CoolDudeMan, Jan 16, 2004.

  1. CoolDudeMan

    CoolDudeMan Guest

    I'm currently working on a class "Course" and I'm getting an
    unresolved external error when trying to compile.

    I understand that unresolved externals are caused by declaration of
    methods that are not defined, but I think I defined all my methods so
    this one has got me stumped. Any help would be much appreciated.

    Thank you for your time,

    Kyle

    course.h
    --------
    #ifndef COURSE_H
    #define COURSE_H

    #include <string>
    using namespace std;

    class Course
    {
    private:
    string id;
    int credithours;
    string instructor;
    string days;
    string time;
    string room;
    int capacity;
    string roster[50];
    int size;
    public:
    Course();// Default Constructor
    void ReadCourse(istream & fin);// Reads course information from
    file.
    void WriteCourse(ostream & fout);// Writes course information to
    file.
    void PrintData();// Prints's all data except roster to screen with
    labels.
    void PrintRoster(ostream & out);// Prints Roster to any output
    stream.
    void AddStudent(ostream & out, string newstudent);// Adds student to
    roster.
    };

    #endif


    Course.cpp
    ----------
    #include "course.h"
    #include <iostream>
    using namespace std;

    Course::Course()
    {
    id="0";
    }

    void Course::ReadCourse(istream & fin)// Reads course information from
    file.
    {
    fin >> id;
    fin >> credithours;
    getline(fin, instructor);
    fin >> days;
    getline(fin, time);
    getline(fin, room);
    fin >> capacity;
    fin >> size;
    for (int i=0; i<=size; i++)
    {
    getline(fin, roster);
    }
    }

    void Course::WriteCourse(ostream & fout)// Writes course information
    to file.
    {
    fout << id << " " << credithours << "\n";
    fout << instructor << "\n";
    fout << days << " " << time << "\n";
    fout << room << "\n";
    fout << capacity << " " << size << "\n";
    for (int i=0; i<=size; i++)
    {
    fout << roster << "\n";
    }
    }

    void Course::printData()// Prints's all data except roster to screen
    with labels.
    {
    cout << "Course ID: " << id << endl;
    cout << "Credits: " << credithours << endl;
    cout << "Instructor: " << instructor << endl;
    cout << "Days and Time: " << days << " " << time << endl;
    cout << "Capacity: " << capacity << endl;
    cout << "Enrolled: " << size << endl;
    }

    void Course::printRoster(ostream & out)// Prints Roster to any output
    stream.
    {
    for (int i=0; i<=size; i++)
    {
    out << roster << endl;
    }
    }

    void Course::AddStudent(ostream & out, string newstudent)// Adds
    student to roster.
    {
    size+=1;
    roster[size]=newstudent;
    }

    ERROR:
    LIBCD.lib(crt0.obj) : error LNK2019: unresolved external symbol _main
    referenced in function _mainCRTStartup
    Debug/Project 1.exe : fatal error LNK1120: 1 unresolved externals
    CoolDudeMan, Jan 16, 2004
    #1
    1. Advertising

  2. CoolDudeMan wrote:
    >
    > I'm currently working on a class "Course" and I'm getting an
    > unresolved external error when trying to compile.


    It is the *linker* which emits this message, not the compiler.
    The linker is trying to assemble the complete executable. And in doing
    so, it noticed that:


    > ERROR:
    > LIBCD.lib(crt0.obj) : error LNK2019: unresolved external symbol _main
    > referenced in function _mainCRTStartup
    > Debug/Project 1.exe : fatal error LNK1120: 1 unresolved externals


    There is no main() function in your program!

    --
    Karl Heinz Buchegger
    Karl Heinz Buchegger, Jan 16, 2004
    #2
    1. Advertising

  3. CoolDudeMan

    CoolDudeMan Guest

    Ah, doh.

    My apologies for my vocabulary (still learning all this stuff. :) )
    but I see the problem now. You just can't build solutions without
    having a mainline function to execute it.

    So, in the future, as long as it gets to the "Linking..." step w/o any
    errors, than the classes and it's implementation and interface files
    are okay.

    Thanks for the help Karl! :)

    -Kyle
    CoolDudeMan, Jan 16, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John Harrison
    Replies:
    0
    Views:
    1,044
    John Harrison
    Jul 20, 2003
  2. Izak Pretorius
    Replies:
    2
    Views:
    1,567
    Christopher
    Sep 14, 2003
  3. Rodolphe
    Replies:
    4
    Views:
    1,060
    Rodolphe
    Oct 3, 2003
  4. Kyle Sheldon

    Unresolved External Help.

    Kyle Sheldon, Jan 16, 2004, in forum: C++
    Replies:
    4
    Views:
    6,359
  5. Scott Allen
    Replies:
    8
    Views:
    10,907
    Scott Allen
    May 2, 2004
Loading...

Share This Page