I am getting the following errors and can't figure out how to fix it:
Start Error Message:
1>------ Build started: Project: Essential, Configuration: Debug Win32 ------
1>Compiling...
1>Essential.cpp
1>c:\users\youlanda\desktop\lan\odu\spring 2011\it 310\program 1 store inventory\essential\essential.cpp(9) : error C2659: '=' : function as left operand
1>c:\users\youlanda\desktop\lan\odu\spring 2011\it 310\program 1 store inventory\essential\essential.cpp(10) : error C2659: '=' : function as left operand
1>c:\users\youlanda\desktop\lan\odu\spring 2011\it 310\program 1 store inventory\essential\essential.cpp(11) : error C2659: '=' : function as left operand
1>c:\users\youlanda\desktop\lan\odu\spring 2011\it 310\program 1 store inventory\essential\essential.cpp(12) : error C2659: '=' : function as left operand
1>c:\users\youlanda\desktop\lan\odu\spring 2011\it 310\program 1 store inventory\essential\essential.cpp(13) : error C2659: '=' : function as left operand
1>c:\users\youlanda\desktop\lan\odu\spring 2011\it 310\program 1 store inventory\essential\essential.cpp(20) : error C2659: '=' : function as left operand
1>c:\users\youlanda\desktop\lan\odu\spring 2011\it 310\program 1 store inventory\essential\essential.cpp(21) : error C2659: '=' : function as left operand
1>c:\users\youlanda\desktop\lan\odu\spring 2011\it 310\program 1 store inventory\essential\essential.cpp(22) : error C2659: '=' : function as left operand
1>c:\users\youlanda\desktop\lan\odu\spring 2011\it 310\program 1 store inventory\essential\essential.cpp(23) : error C2659: '=' : function as left operand
1>c:\users\youlanda\desktop\lan\odu\spring 2011\it 310\program 1 store inventory\essential\essential.cpp(24) : error C2659: '=' : function as left operand
1>c:\users\youlanda\desktop\lan\odu\spring 2011\it 310\program 1 store inventory\essential\essential.cpp(25) : error C2659: '=' : function as left operand
1>c:\users\youlanda\desktop\lan\odu\spring 2011\it 310\program 1 store inventory\essential\essential.cpp(32) : error C2556: 'int &Essential::GetProductID(void) const' : overloaded function differs only by return type from 'int Essential::GetProductID(void) const'
1> c:\users\youlanda\desktop\lan\odu\spring 2011\it 310\program 1 store inventory\essential\essential.h(24) : see declaration of 'Essential::GetProductID'
1>c:\users\youlanda\desktop\lan\odu\spring 2011\it 310\program 1 store inventory\essential\essential.cpp(32) : error C2040: 'Essential::GetProductID' : 'int &(void) const' differs in levels of indirection from 'int (void) const'
1>c:\users\youlanda\desktop\lan\odu\spring 2011\it 310\program 1 store inventory\essential\essential.cpp(37) : error C2556: 'int &Essential::GetManufacturersID(void) const' : overloaded function differs only by return type from 'int Essential::GetManufacturersID(void) const'
1> c:\users\youlanda\desktop\lan\odu\spring 2011\it 310\program 1 store inventory\essential\essential.h(25) : see declaration of 'Essential::GetManufacturersID'
1>c:\users\youlanda\desktop\lan\odu\spring 2011\it 310\program 1 store inventory\essential\essential.cpp(37) : error C2040: 'Essential::GetManufacturersID' : 'int &(void) const' differs in levels of indirection from 'int (void) const'
1>c:\users\youlanda\desktop\lan\odu\spring 2011\it 310\program 1 store inventory\essential\essential.cpp(42) : error C2556: 'int &Essential::GetQuantityOfProduct(void) const' : overloaded function differs only by return type from 'int Essential::GetQuantityOfProduct(void) const'
1> c:\users\youlanda\desktop\lan\odu\spring 2011\it 310\program 1 store inventory\essential\essential.h(26) : see declaration of 'Essential::GetQuantityOfProduct'
1>c:\users\youlanda\desktop\lan\odu\spring 2011\it 310\program 1 store inventory\essential\essential.cpp(42) : error C2040: 'Essential::GetQuantityOfProduct' : 'int &(void) const' differs in levels of indirection from 'int (void) const'
1>c:\users\youlanda\desktop\lan\odu\spring 2011\it 310\program 1 store inventory\essential\essential.cpp(47) : error C2556: 'double &Essential::GetWholeSalePrice(void) const' : overloaded function differs only by return type from 'double Essential::GetWholeSalePrice(void) const'
1> c:\users\youlanda\desktop\lan\odu\spring 2011\it 310\program 1 store inventory\essential\essential.h(27) : see declaration of 'Essential::GetWholeSalePrice'
1>c:\users\youlanda\desktop\lan\odu\spring 2011\it 310\program 1 store inventory\essential\essential.cpp(47) : error C2040: 'Essential::GetWholeSalePrice' : 'double &(void) const' differs in levels of indirection from 'double (void) const'
1>c:\users\youlanda\desktop\lan\odu\spring 2011\it 310\program 1 store inventory\essential\essential.cpp(52) : error C2556: 'double &Essential::GetMarkUpPercentage(void) const' : overloaded function differs only by return type from 'double Essential::GetMarkUpPercentage(void) const'
1> c:\users\youlanda\desktop\lan\odu\spring 2011\it 310\program 1 store inventory\essential\essential.h(28) : see declaration of 'Essential::GetMarkUpPercentage'
1>c:\users\youlanda\desktop\lan\odu\spring 2011\it 310\program 1 store inventory\essential\essential.cpp(52) : error C2040: 'Essential::GetMarkUpPercentage' : 'double &(void) const' differs in levels of indirection from 'double (void) const'
1>c:\users\youlanda\desktop\lan\odu\spring 2011\it 310\program 1 store inventory\essential\essential.cpp(58) : error C2440: 'return' : cannot convert from 'char *[30]' to 'char *'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>c:\users\youlanda\desktop\lan\odu\spring 2011\it 310\program 1 store inventory\essential\essential.cpp(67) : error C2264: 'Essential::GetProductID' : error in function definition or declaration; function not called
1>c:\users\youlanda\desktop\lan\odu\spring 2011\it 310\program 1 store inventory\essential\essential.cpp(68) : error C2264: 'Essential::GetManufacturersID' : error in function definition or declaration; function not called
1>c:\users\youlanda\desktop\lan\odu\spring 2011\it 310\program 1 store inventory\essential\essential.cpp(69) : error C2264: 'Essential::GetQuantityOfProduct' : error in function definition or declaration; function not called
1>c:\users\youlanda\desktop\lan\odu\spring 2011\it 310\program 1 store inventory\essential\essential.cpp(70) : error C2264: 'Essential::GetWholeSalePrice' : error in function definition or declaration; function not called
1>c:\users\youlanda\desktop\lan\odu\spring 2011\it 310\program 1 store inventory\essential\essential.cpp(71) : error C2264: 'Essential::GetMarkUpPercentage' : error in function definition or declaration; function not called
1>EssentialClientCode.cpp
1>Generating Code...
End of Error Message:


Beginning of Source Code:
// Implementation File (Essential.cpp)

#include "Essential.h"

// Constructors

Essential::Essential()
{
	ProductID = 0;
	ManufacturersID = 0;
	QuantityOfProduct = 0;
	WholeSalePrice = 0;
	MarkUpPercentage = 0;
	ProductDescription[30] = '\0';
}	

Essential::Essential(int InitProductID, int InitManufacturersID, int InitQuantityOfProduct, 
					 double InitWholeSalePrice, double InitMarkUpPercentage, char InitProductDescription[])
{
	ProductID = InitProductID;
	ManufacturersID = InitManufacturersID;
	QuantityOfProduct = InitQuantityOfProduct;
	WholeSalePrice = InitWholeSalePrice;
	MarkUpPercentage = InitMarkUpPercentage;
	strcpy_s= (ProductDescription, InitProductDescription);

}

// Return the Value of the Private Class Members

int Essential::GetProductID() const
{
	return (ProductID);
}

int Essential::GetManufacturersID() const
{
	return (ManufacturersID);
}

int Essential::GetQuantityOfProduct() const
{
	return (QuantityOfProduct);
}

double Essential::GetWholeSalePrice() const
{
	return (WholeSalePrice);
}

double Essential::GetMarkUpPercentage() const
{
	return (MarkUpPercentage);
}

char* Essential::GetProductDescription() const
{
	return (ProductDescription);
}

// Display Information

void Essential::Display() const
{
	//Display Data for Essential

	cout << GetProductID() <<endl;
	cout << GetManufacturersID() << endl;
	cout << GetQuantityOfProduct() << endl;
	cout << GetWholeSalePrice() <<endl;
	cout << GetMarkUpPercentage() << endl;
	cout << GetProductDescription() << endl;
}

Recommended Answers

All 4 Replies

Check out line 23 - what's that equal sign ("=") all about? Remove that and see what happens.

Check out line 23 - what's that equal sign ("=") all about? Remove that and see what happens.

There is substantially more going on here than just that. The problem is, the OP didn't give us the header, so we don't know how the class is declared. The errors are being reported in the *.cpp file, but I suspect that they are being partially caused by something in the header.

Based on what I'm seeing, I'm guessing the data members aren't declared properly.

as far as I see, he needs == instead of = as he is declaring them as int and double..
Making them equal a number rather than comparing them to true or false.

As for the char* cant be converted to char[30] thats an error on his part at

char* Essential::GetProductDescription() const
{
return (ProductDescription);

as far as I see, he needs == instead of = as he is declaring them as int and double..
Making them equal a number rather than comparing them to true or false.

As for the char* cant be converted to char[30] thats an error on his part at

char* Essential::GetProductDescription() const
{
return (ProductDescription);

What you are referring to is a relational/comparison statement for a conditional. There aren't any conditional statements in the posted code. With exception of Line 23, using '=' is correct. The functions they exist in are constructors. It is appropriate that all the statements are assignment statements.

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.