Thread: weird

  1. #1
    Registered User
    Join Date
    Nov 2005
    Posts
    10

    weird

    hello, i have written this little piece of code which does nothing. i am using VC++ 6.0 and it compiles fine, but when i try to build it it says:

    Linking...
    main.obj : error LNK2001: unresolved external symbol "public: void __thiscall lol::ask(void)" (?ask@lol@@QAEXXZ)
    Debug/game.exe : fatal error LNK1120: 1 unresolved externals
    Error executing link.exe.

    game.exe - 2 error(s), 0 warning(s)


    Pls help!

    Code:
    #include <iostream.h>
    #include <stdlib.h>
    
    class lol 
    {
    public:	
    	void ask();
    private:
    	
    	
    };
    
    void ask()
    	{
    	    
    		cout <<"Ghiceste: \n";
    		cout << "he he he he he";
    		
    	};
    
    int main()
    {
    	lol pc;
    	//nr1 = rand() % 100;
    	cout << "******** ala_negru ******** \n";
    	cout <<"\n Calculatorul se gandeste la un nr pe care tu trebuie sa-l ghicesti.\n";
    	cout <<"De asemenea iti va spune daca nr tau e mai mare sau mai mic decat al lui. \n";
    	pc.ask();
    	return 0;
    }

  2. #2
    Bond sunnypalsingh's Avatar
    Join Date
    Oct 2005
    Posts
    162
    Here is the corrected code
    Code:
    #include <iostream>
    #include <cstdlib>
    using namespace std;
    
    class lol 
    {
    public:	
    	void ask();
    private:
    	
    	
    };
    
    void lol:: ask()
    	{
    	    
    		cout <<"Ghiceste: \n";
    		cout << "he he he he he";
    		
    	}
    
    int main()
    {
    	lol pc;
    	//nr1 = rand() % 100;
    	cout << "******** ala_negru ******** \n";
    	cout <<"\n Calculatorul se gandeste la un nr pe care tu trebuie sa-l ghicesti.\n";
    	cout <<"De asemenea iti va spune daca nr tau e mai mare sau mai mic decat al lui. \n";
    	pc.ask();
    	return 0;
    }
    See the red line(u need to specify the scope of the function).....i changed the headers and removed the extra semicolon after function defination.....
    Last edited by sunnypalsingh; 11-11-2005 at 06:49 AM.

  3. #3
    Registered User
    Join Date
    Nov 2005
    Posts
    10
    lol man! how could i have been so stupid?!? thankx!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. weird things with my linked list of queue
    By -EquinoX- in forum C Programming
    Replies: 3
    Last Post: 11-22-2008, 11:23 PM
  2. weird
    By kiz in forum C Programming
    Replies: 8
    Last Post: 09-24-2007, 01:16 AM
  3. Weird Characters With GetDlgItemText
    By execute in forum Windows Programming
    Replies: 4
    Last Post: 05-04-2006, 04:53 PM
  4. weird error
    By gandalf_bar in forum Linux Programming
    Replies: 2
    Last Post: 07-17-2005, 07:32 AM
  5. Getting weird characters in Strings
    By steve8820 in forum C Programming
    Replies: 3
    Last Post: 09-18-2001, 02:49 AM