The old 'turtle' program....help with it compiling to start

This is a discussion on The old 'turtle' program....help with it compiling to start within the C++ Programming forums, part of the General Programming Boards category; I am working a variation of the 'turtle' program. I was given this code by the instructor, and I just ...

  1. #1
    Registered User
    Join Date
    Oct 2010
    Posts
    5

    The old 'turtle' program....help with it compiling to start

    I am working a variation of the 'turtle' program.

    I was given this code by the instructor, and I just want it to compile first, but I am getting these errors using Studio 08.

    #########################################

    Error 1 error LNK2019: unresolved external symbol "public: void __thiscall TurtleGraphics:rocessTurtleMoves(int const * const)" (?processTurtleMoves@TurtleGraphics@@QAEXQBH@Z) referenced in function _main Assign6.obj turtle

    Error 2 error LNK2019: unresolved external symbol "public: __thiscall TurtleGraphics::TurtleGraphics(void)" (??0TurtleGraphics@@QAE@XZ) referenced in function _main Assign6.obj turtle

    Error 3 fatal error LNK1120: 2 unresolved externals C:\Documents and Settings\a00774161\Desktop\turtle\turtle\Debug\tur tle.exe 1 turtle

    ##########################################

    Code:
    //Turtle.cpp
    #include <iostream>
    using namespace std;
    #include "TurtleGraphics.h"
    
    int main()
    {
       int cmds[] = {5,5,4,5,9,2,5,12, 1,};     // go to start of page and put pen down
    
       TurtleGraphics turtleOne;  // create a TurtleGraphics object
    
       turtleOne.processTurtleMoves(cmds); // have turtle process commands
    
    cout << "end of program\n\n"; // for testing purpose
    
       system("pause");
       return 0;  // we are finished, let's go home
    }
    Code:
    //TurtleGraphics.h
    #pragma once
    
    class TurtleGraphics
    {
    private:
    	const static int NROWS = 22; 
    	const static int NCOLS = 70;  
    
    	const static int STARTING_ROW = 0;   
    	const static int STARTING_COL = 0;   
    
    	const static int STARTING_DIRECTION = 6; //12 = up, 3 = right, 6 = down, 9 = left
    
    	const static bool STARTING_PEN_POSITION = false; 
    
    	void displayFloor();  // will display floor on the screen
    
    	bool m_Floor [NROWS][NCOLS];   // floor on which turtle will draw
    
    public:
    	TurtleGraphics(void); //ctor will init. floor to all "false" values, 
    	                      
    	void processTurtleMoves( const int commands[]);  
                  
    	
    };

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,834
    So where is TurtleGraphics.cpp to match your TurtleGraphics.h file?

    If you have such a file, then you need to add it to the project->settings->source files list (along with your Turtle.cpp)

    If you don't have such a file, then it should be in a library somewhere, given to you by your tutor.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Oct 2010
    Posts
    5
    I am not sure that I require a TurtleGraphics.cpp file.

    it compiles now - I changed

    in the TurtleGraphics.h file
    Code:
    void processTurtleMoves(const int commands[]);
    to

    Code:
    	void processTurtleMoves(const int commands[]) 
    	{
    
    		return;
    	}

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,834
    Well yeah, except processTurtleMoves() probably did something, and now it does nothing.

    The real something will be in the .cpp file you're so keen to dismiss as irrelevant.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Hi, Quiz C program Assignment updated
    By Eman in forum C Programming
    Replies: 19
    Last Post: 11-22-2009, 04:50 PM
  2. C compiling / error: stray \ in program
    By Elya in forum C Programming
    Replies: 5
    Last Post: 07-02-2009, 09:20 AM
  3. Help Needed with Compiling C program
    By girishaneja in forum C Programming
    Replies: 2
    Last Post: 05-20-2009, 09:10 AM
  4. Start program before login with WinXP
    By Icewind2003 in forum Tech Board
    Replies: 3
    Last Post: 02-12-2003, 04:50 PM
  5. fopen();
    By GanglyLamb in forum C Programming
    Replies: 8
    Last Post: 11-03-2002, 12:39 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21