C++ Problem

cosmicsafari

New Member
Messages
10
Reaction score
0
Points
0
Hey guyz, im quite new to C++ and i keep getting this problem,

1>MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup

As far as i am aware it has something to do with a: An undefined external symbol (symbol) was found in function. To resolve this error, provide a definition for symbol or remove the code that references it.

CODE----------------------------------------------

#include "LinkedList.h" //import header file
#include <ctime> //for time()
#include <time.h>
#include <cstdlib> //library for srand() and rand()
#include <conio.h> //for getch();


int main(){

LinkedList Munro_List; //create linked list called Munro_List

//create 40 munros and populate each detail of the munro randomly
for (int ID=1 ; ID<=40 ; ID++)
{
Munro_List.generateHills (
//ID, //Hill ID value
(rand() % 1400) + 3000, //Hill height randomly generated
(rand() % 280) + 20, //Hill distance from home randomly generated
false, //Previously climbed value set to false i.e not climbed
(rand() % 280) + 20,
(rand() % 100000) + 400000); //Grid reference of hill randomly generated
}

return 0;

}
CODE END---------------------------------------

Im stumped, any help would greatly be appreciated =D
 

DeadBattery

Community Support Team
Community Support
Messages
4,018
Reaction score
120
Points
0
May I have a look at your header file?
It appears to be there is a problem within the header file, not the C++ program itself.
 

cosmicsafari

New Member
Messages
10
Reaction score
0
Points
0
Sure thing ill post a copy once i get home from work ^_^
Edit:
Heres the files for build.

-------------MAIN----------------
#include "LinkedList.h" //import header file
#include <ctime> //for time()
#include <time.h>
#include <cstdlib> //library for srand() and rand()
#include <conio.h> //for getch();


int main(){

LinkedList Munro_List; //create linked list called Munro_List

//create 40 munros and populate each detail of the munro randomly
for (int ID=1 ; ID<=40 ; ID++)
{
Munro_List.generateHills (
//ID, //Hill ID value
(rand() % 1400) + 3000, //Hill height randomly generated
(rand() % 280) + 20, //Hill distance from home randomly generated
false, //Previously climbed value set to false i.e not climbed
(rand() % 280) + 20,
(rand() % 100000) + 400000); //Grid reference of hill randomly generated
}

return 0;
};


-------.CPP---------------------------
#include "LinkedList.h"
#include <conio.h> //used for getch();

LinkedList::LinkedList(){ //constructor

count = 0;
Head = NULL;
Previous = NULL;
}


//--------------Function to create new munros(nodes) and populate them with data---------------------------
void LinkedList:: generateHills(int A,int B,bool C,int D,int E){
MunroRecord *Next_Node; //declare pointer to node called nextNode
Next_Node = new MunroRecord; //create new node

Next_Node->height = A; //set value of hill height to equal parameter A
Next_Node->distanceFromHome = B; //set value of distance from home to equal parameter B
Next_Node->climbed = C; //set value of previous climbed to equal parameter C
Next_Node->timesClimbed = D; //set value of times climbed to equal parameter D
Next_Node->gridReference = E; //set value of grid reference to equal parameter E

Next_Node->Head = FirstNode; // give the node’s next field the value currently in Pointer_To_First
//i.e. the new node now points to the old first node
FirstNode = Next_Node; //and the Pointer_To_First now points to the new node
FirstNode->Previous = Next_Node;
count++; // 1 is added to counter to include the new node in the total number of nodes

if(LastNode == NULL){ //if there are currently no nodes in the list the linked list’s
LastNode = Next_Node; // “Pointer_To_Last” field also points to the new node, as it both the
} //first and Pointer_To_Last node.
}

----------HEADER------------------------
#include <iostream>
using namespace std;

struct MunroRecord{
int height; //height of hill in feet
int distanceFromHome; //distance in miles from home
bool climbed; //whether climbed
int timesClimbed; //number of times climbed
int gridReference; //6 digit grid reference

MunroRecord *Head;
MunroRecord *Previous;
};


//define a node as a structure
//struct Node{
//MunroRecord data; //data about a hill in each node
//Node *link; //declares node pointer called link
//};



class LinkedList{
private:
MunroRecord *FirstNode; //declares node pointer called head
MunroRecord *LastNode; //declares node pointer called last
int count;
public:
LinkedList();
void generateHills(int A,int B,bool C,int D,int E);
void insertNodeAtEnd(MunroRecord newinfo);
int getNodeCount();
//Node* getHead();
MunroRecord *Head;
MunroRecord *Previous;
};




Any help would be greatly appreciated ^_^
 
Last edited:

VPmase

New Member
Messages
914
Reaction score
1
Points
0
Moved to off-topic since it doesn't have anything to do with web design or development.
 

DeadBattery

Community Support Team
Community Support
Messages
4,018
Reaction score
120
Points
0
@comicsafari: What did you call ".CPP"? Is that part of the "main" file or is it a separate file?
 

cosmicsafari

New Member
Messages
10
Reaction score
0
Points
0
It is 3 seperate files

LinkedList.h
LinkedList.cpp
main.cpp

i have heard that it is possible with only 2 files, but my lecturer specified that we use 3 for some reason.

Thanks
 
Last edited:
Top