Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Help with Unresolved External.

Reply
Thread Tools

Help with Unresolved External.

 
 
CoolDudeMan
Guest
Posts: n/a
 
      01-16-2004
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[i]);
}
}

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[i] << "\n";
}
}

void Course:rintData()// 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:rintRoster(ostream & out)// Prints Roster to any output
stream.
{
for (int i=0; i<=size; i++)
{
out << roster[i] << 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
 
Reply With Quote
 
 
 
 
Karl Heinz Buchegger
Guest
Posts: n/a
 
      01-16-2004
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

 
Reply With Quote
 
 
 
 
CoolDudeMan
Guest
Posts: n/a
 
      01-16-2004
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
JNI - unresolved _ZNSs4_Rep11_S_terminalE FBergemann@web.de Java 4 06-10-2005 07:12 AM
Unresolved import javax.servlet under Netbeans 4.0 Andrew Mayo Java 1 01-31-2005 12:39 PM
resolved/unresolved signal?! jozo VHDL 1 05-16-2004 02:47 PM
Unresolved External Help. Kyle Sheldon C++ 4 01-16-2004 07:39 PM
Re: unresolved external symbol error. Need help! John Harrison C++ 0 07-20-2003 07:18 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57