+ Reply to Thread
Results 1 to 6 of 6

Thread: C++ Problem

  1. #1
    cosmicsafari's Avatar
    cosmicsafari is offline x10Hosting Member cosmicsafari is an unknown quantity at this point
    Join Date
    May 2008
    Location
    Scotland
    Posts
    10

    C++ Problem

    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
    "Knowledge speaks, but wisdom listens."
    Jimi Hendrix

  2. #2
    DeadBattery's Avatar
    DeadBattery is offline Community Support Team DeadBattery is a name known to allDeadBattery is a name known to all
    Join Date
    Mar 2008
    Location
    localhost
    Posts
    4,019

    Re: C++ Problem

    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.


  3. #3
    cosmicsafari's Avatar
    cosmicsafari is offline x10Hosting Member cosmicsafari is an unknown quantity at this point
    Join Date
    May 2008
    Location
    Scotland
    Posts
    10

    Re: C++ Problem

    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 by cosmicsafari; 07-15-2008 at 03:56 PM. Reason: Automerged Doublepost
    "Knowledge speaks, but wisdom listens."
    Jimi Hendrix

  4. #4
    VPmase's Avatar
    VPmase is offline x10 Elder VPmase is an unknown quantity at this point
    Join Date
    Nov 2007
    Location
    Dixon, IL, USA
    Posts
    914

    Re: C++ Problem

    Moved to off-topic since it doesn't have anything to do with web design or development.

  5. #5
    DeadBattery's Avatar
    DeadBattery is offline Community Support Team DeadBattery is a name known to allDeadBattery is a name known to all
    Join Date
    Mar 2008
    Location
    localhost
    Posts
    4,019

    Re: C++ Problem

    @comicsafari: What did you call ".CPP"? Is that part of the "main" file or is it a separate file?


  6. #6
    cosmicsafari's Avatar
    cosmicsafari is offline x10Hosting Member cosmicsafari is an unknown quantity at this point
    Join Date
    May 2008
    Location
    Scotland
    Posts
    10

    Re: C++ Problem

    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 by cosmicsafari; 07-16-2008 at 03:13 AM.
    "Knowledge speaks, but wisdom listens."
    Jimi Hendrix

+ Reply to Thread

Similar Threads

  1. DB number problem
    By lionheart8 in forum Free Hosting
    Replies: 5
    Last Post: 04-08-2008, 08:26 AM
  2. Problem with SMF
    By tam-iam in forum Free Hosting
    Replies: 5
    Last Post: 08-21-2007, 03:20 PM
  3. Apache + mod_rewrite problem
    By t2t2t in forum Free Hosting
    Replies: 3
    Last Post: 06-27-2007, 11:37 AM
  4. Problem with ad code (includes?)
    By Salvatos in forum Free Hosting
    Replies: 10
    Last Post: 12-12-2006, 04:16 PM
  5. Ad code problem!
    By Akkarin in forum Free Hosting
    Replies: 8
    Last Post: 08-29-2005, 10:39 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers