Link errors- first time user

Hi folks,
I am building my first very simple package but got stuck with some link errors.
Error look like this:
Error 1 error LNK2019: unresolved external symbol "public: void __thiscall Display::displaystring(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?displaystring@Display@@QAEXV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function _main C:\Users\Proj1_FileMgrDemo\temp1\temp\ConsoleApplication1\Display\Display.obj Display


Error 2 error LNK1120: 1 unresolved externals C:\Users\Proj1_FileMgrDemo\temp1\temp\ConsoleApplication1\Debug\Display.exe Display


Code I have written is below

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

#include "stdafx.h"
#include<string>
#include<iostream>
#include "Display.h"


void displaystring(std::string a)
{
	std::cout << "\n" << a << std::endl;
}



void main(int argc, char* argv[])
{
	std::string mystring; 
	mystring = "Hi This is a new line";
	Display ds;
	ds.displaystring(mystring);

}


1
2
3
4
5
6
7
8
9
10
11
12
13
Display.h


#include<string>
#include<iostream>

class Display {
public:
	void displaystring(std::string a);

};


Last edited on
You have not defined the function displaystring for your Display class.

In Display.cpp, you should have a function which has the following signature:
void Display::displaystring(std::string a);
thank u... that worked
Topic archived. No new replies allowed.