This code is a tutorial, from internet, I can make it to compile,
error to advance for me, (+) use is a ???? for me, using MV C++.
Is a class tutorial.....

#include<iostream>
#include<iomanip>
#include<string>
using namespace std;


class Food
{
private:
	//instance variable.Every object wiil have this variables.....
	string mFoodName;
	double mFoodPrice;
	//class variable.Will be only one for the class.....
	static int sCount;
public:
	Food(string mFoodName  = "Steak", double mFoodPrice = 13.67);
	//Copy Constructor...................
	Food(Food &food){
		sCount++;
		mFoodName = food.mFoodName;
		mFoodPrice = food.mFoodPrice;
		cout << " Food HI Copy Constructor : " + mFoodName << endl;
	}
	~Food(){
		sCount--;
		cout << " Food BYE Destructor: " + mFoodName + " " << sCount << endl;
	}
	void Display();

	void ChangeFood(string foodName, double foodPrice){
		mFoodName  = foodName;
		mFoodPrice = foodPrice;
	}
};
//initialaze class variable........outside of class
int Food::sCount = 0;				// with the scope resolute indicator(::) to indicate scount is variable of Food class.
void ModifyFood(Food &food);
Food ChangeFood(Food food);
int main(void)
{
	Food f1;
	Food f2("Ham");
	Food f3("Chicken", 6.54);

	ModifyFood(f2);
	f1.Display();
	f2.Display();
	f3.Display();

	Food f5 = ChangeFood(f3);
	f5.Display();
	Food f4 = f2;
	f4.Display();
	cout << " Leave main() " << endl << endl;
system("pause");
return 0;
}
void ModifyFood(Food &food){
	cout << " Enter ModifyFood() " << endl;
	food.Display();
	food.ChangeFood("Pork Chops", 5.77);
	cout << " Leave ModifyFood() " << endl << endl;
}
Food ChangeFood(Food food){
	cout << " Enter ChangeFood() " << endl;
	food.ChangeFood("Prime Rib", 16.54);
	food.Display();
	cout << " Leave ChangeFood() " << endl << endl;
	return food;
}

Please provide the full error from the compiler.

There is plenty of memory available on the C++ forum server so please try to use complete sentences to clearly explain your problem and ask a pertinent question. As it stands I don't have the foggiest idea what question you are asking or assistance you areseeking.

Maybe a moderator will change the format of the post to the default thread type instead of a code snippet as the responses look a bit weird otherwise.

------ Build started: Project: Class_CWMDeVry_Utube, Configuration: Debug Win32 ------
Linking...
Class_CWMDeVry_Utube_VariableScopeCopyConstructor_main.obj : error LNK2019: unresolved external symbol "public: void __thiscall Food::Display(void)" (?Display@Food@@QAEXXZ) referenced in function _main
Class_CWMDeVry_Utube_VariableScopeCopyConstructor_main.obj : error LNK2019: unresolved external symbol "public: __thiscall Food::Food(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,double)" (??0Food@@QAE@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@N@Z) referenced in function _main
C:\Documents and Settings\Omar\My Documents\Visual Studio 2008\Class_CWMDeVry_Utube\Debug\Class_CWMDeVry_Utube.exe : fatal error LNK1120: 2 unresolved externals
Build log was saved at "file://c:\Documents and Settings\Omar\My Documents\Visual Studio 2008\Class_CWMDeVry_Utube\Class_CWMDeVry_Utube\Debug\BuildLog.htm"
Class_CWMDeVry_Utube - 3 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

The Display() member function is declared but not defined. Therefore the linker can't link to the function definition and it sends an uresolved external symbol error.

commented: Thanks +0

This code is from a U_tube tutorial, is posted under the username CWMDeVry, I don't ever use <iomapi> before, the use of (+), in line 22 and 26 is something that I'm assuming is like a (<<) operator,..... is a guess, maybe the hole problem don't have anything to do with this....and just really new to c++ and also to this side, but there is first time for everything in life.....Do I did posted in the wrong site or forum?

This is the correct forum to ask questions about the code you posted, though using code tags to post the code instead of posting it as a code snippet would have been better, in my opinion.

I have no idea what context the code snippet you posted was used in the tutorial you found it in. Maybe it was designed as an exercise in learning how to debug code or to force the student to implement their own version of Display() . Maybe the person who posted it didn't know what they were doing. I can't tell from the information I have.

The current point is that the list of error messages you posted should be tackled starting with the first error message and then recompiling. The first error message relates to the inability of the compiler/linker to know what to do when the Display() method is called on lines 46, 47, 48, etc in main() because there is no instruction as to what to do since the Display() method is declared but not defined using either an inline technique, like the ChangeFood() method was, or using the more typical approach by defining (also called implementing) the method outside of the declaration not using inline technique (I forget the technical term for defining methods outside of the declaration).

assuming your code is in one file for the class you should use inline in front like this:

inline void ChangeFood(string foodName, double foodPrice){
		mFoodName  = foodName;
		mFoodPrice = foodPrice;
	}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.