HELP!!Why and How to solve this linking errors.

This is a discussion on HELP!!Why and How to solve this linking errors. within the C++ Programming forums, part of the General Programming Boards category; What's wrong?Please help! No compile error but I got this linking errors :- Code: Compiling... main.cpp Linking... Test_Display.obj : error ...

  1. #1
    Registered User
    Join Date
    Apr 2007
    Posts
    30

    HELP!!Why and How to solve this linking errors.

    What's wrong?Please help!

    No compile error but I got this linking errors :-

    Code:
    Compiling...
    main.cpp
    Linking...
    Test_Display.obj : error LNK2001: unresolved external symbol "public: void __thiscall Test_Text::test_put_text(char *)" (?test_put_text@Test_Text@@QAEXPAD@Z)
    Test_Display.obj : error LNK2001: unresolved external symbol "public: void __thiscall Test_Display::test_put_display(char *)" (?test_put_display@Test_Display@@QAEXPAD@Z)
    Test_Display.obj : error LNK2001: unresolved external symbol "public: void __thiscall Test_Indicator::test_put_indicator(char *)" (?test_put_indicator@Test_Indicator@@QAEXPAD@Z)
    Debug/H1.exe : fatal error LNK1120: 3 unresolved externals
    Error executing link.exe.
    
    H1.exe - 4 error(s), 0 warning(s)


    Here are the .cpp and .h files:-

    Code:
    1) Test_Display.h
    
    #ifndef TEST_DISPLAY_H
    #define TEST_DISPLAY_H
    
    #include "Sum_Class.h"
    
    class TestDisplay
    {
    	public:
    		TestDisplay();
    		TestDisplay(int);
    		void put_text (char *text);
    		void put_indicator (char *text);
    		void put_display (char *text);
    
    
    	private:
    		Test_Indicator* m_ptr_ind;
    		Test_Text* m_ptr_text;
    		Test_Display* m_ptr_display;
    
    };
    
    #endif TEST_DISPLAY_H

    Code:
    2) Test_Display.cpp
    
    #include <iostream.h>
    #include "Test_Display.h"
    #include "Sum_Class.h"
    
    TestDisplay::TestDisplay (int displayType)
    {
    		m_ptr_ind = new Test_Indicator(displayType);
    		m_ptr_text = new Test_Text(displayType);
                                    m_ptr_display = new Test_Display(displayType);
    
    		
    }
    
    
    
    void TestDisplay::put_text (char *text)
    {
    	m_ptr_text->test_put_text(text);
    }
    
    void TestDisplay::put_display (char *text)
    {
    	m_ptr_display->test_put_display(text);
    }
    
    void TestDisplay::put_indicator (char *text)
    {
    	m_ptr_ind->test_put_indicator(text);
    }

    Code:
    3) Sum_Class.h
    
    #ifndef SUM_CLASS_H
    #define SUM_CLASS_H
    
    
    class Test_Text 
    {
      public:
                   Test_Text(int x) {display_id = x;}
    	void test_put_text(char *str);
      private:
    	int display_id;
    	
    };
    
    class Test_Display 
    {
      public:
    	  Test_Display(int x) {display_id = x;}
    	  void test_put_display(char *str);
      private:
    	int display_id;
    
    };
    
    class Test_Indicator 
    {
      public:
    	  Test_Indicator(int x) { display_id = x;}
    	  void test_put_indicator(char *str);
      private:
    	int display_id;
    
    };
    
      
    #endif // SUM_CLASS_H

    Code:
    4) main.cpp
    
    #include <iostream.h>
    #include "Test_Display.h"
    
    #define TOP 0
    #define FRONT 1
    
    void main(void)
    {
    	TestDisplay *TestArr[2];
    
    	TestArr[TOP] = new TestDisplay(TOP);
    	TestArr[FRONT] = new TestDisplay(FRONT);
    	
    
    }

  2. #2
    Registered User
    Join Date
    Feb 2006
    Posts
    312
    Wheres the implementation of those functions? You have only posted the declarations in Sum_Class.h

  3. #3
    Registered User
    Join Date
    Apr 2007
    Posts
    30
    Oh yeah!very good question!
    Your question solved my problem
    After adding the implementation for the functions in Sum_Class.h, problem solved!!
    Thanks a lot!!

  4. #4
    Sanity is for the weak! beene's Avatar
    Join Date
    Jul 2006
    Posts
    321
    Oh, and by the way, use int main() instead of void main(void).

Popular pages Recent additions subscribe to a feed

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