2 Replies - 1186 Views - Last Post: 05 July 2016 - 08:23 PM

#1 rubbaduckie0815  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 1
  • View blog
  • Posts: 26
  • Joined: 11-June 15

Undeclared Identifier and undefined class

Posted 05 July 2016 - 06:05 PM

Hi All,
I am having some issues with the declaration of a class Products. When I try and declare it with in the StoreInventory_Form.h, I get the errors down at the bottom. I'm not sure what I am missing that could be causing this. I have included all the needed files. I didn't include all of the StoreInventory_Form.h because this was the only instance of an issue so far. Any help or ideas on how to resolve this issue would be great. This was a test for one variable before i started to get into numerous different variables that i need to.

stdafx.h
#pragma once

#include "StoreInventoryGUI.h"



StoreInventoryGUI.h
#ifndef STOREINVENTORYGUI_H
#define STOREINVENTORYGUI_H

#include <string>
#include <iostream>
#include <iomanip>

using namespace std;

class Products
{
public:
	Products();
	Products(char []);

	char* getProDES()
		{return (proDES);}
  
	double getRetailPrice();
	void print();


private:
	
	mutable char proDES[25];
	double retailPr;
};

#endif



StoreInventory_GUI.cpp
//#include "StoreInventory.h"
#include "stdafx.h"

Products::Products()
{

	proDES[25] = '\0';

}
Products::Products(char initProDES[])
{
      strcpy_s(proDES, initProDES);

}

double Products::getRetailPrice()
{
	double WHSL_temp = 15.00;//getWhlslPr();
	double MKUP_temp = .2;//getMarkUp_Prec();

	retailPr = WHSL_temp;
	retailPr += (WHSL_temp * MKUP_temp);

	return retailPr;
}

void Products::print()
{

	cout << "|=======================================================|\n"
		 << "|           Office Supply Product Information           |\n"
		 << "|=======================================================|\n"
		 << "|=======================================================|\n";


	cout << "|" << setw(19) << setfill(' ') << right << "Description:"
		 << setw(34) << setfill(' ') << right << getProDES()
		 << setw(4) << setfill(' ') << right <<"|\n";

	cout << "|=======================================================|\n";

	cout << "\nOffice Supply Product Retail Price: $" 
		 << getRetailPrice() <<endl;
}



StoreInventory_Form.h
private: System::Void InputOneText_Click(System::Object^ sender, System::EventArgs^ e)
		{
			InputOneText->Clear();
			OutputOneText->Clear();
		}	

private: System::Void ExitButton_Click(System::Object^ sender, System::EventArgs^ e)
		{
			Application::Exit();
		}
private: System::Void DisplayButton_Click(System::Object^ sender, System::EventArgs^ e)
		{
			 
			char* InitProDES;
			

			String^ TypeString;

			InitProDES = (char*)(void*)Marshal::StringToHGlobalAnsi(InputOneText->Text);

			Products firstProduct(InitProDES);

			TypeString = gcnew String(firstProduct.getProDES());
			OutputOneText->Text = TypeString;



		}	


StoreInevtory_test_GUI_MAIN.cpp
#include "stdafx.h"
#include "StoreInventory_Form.h"

using namespace StoreInventory_test_GUI;

[STAThreadAttribute]
int main(array<System::String ^> ^args)
{
	Application::EnableVisualStyles();
	Application::SetCompatibleTextRenderingDefault(false);

	Application::Run(gcnew StoreInventory_Form());

return 0;
}



Errors
Error	1	error C2065: 'Products' : undeclared identifier                           163	1   StoreInventory_test_GUI
Error	2	error C2146: syntax error : missing ';' before identifier 'firstProduct'  163	1   StoreInventory_test_GUI
Error	3	error C3861: 'firstProduct': identifier not found                         163	1   StoreInventory_test_GUI
	4	IntelliSense: identifier "Products" is undefined                          163	4   StoreInventory_test_GUI




To be honest with you I'm not to sure what i missed. If it take the two lines out referencing the Class Products it will compile fine.

Is This A Good Question/Topic? 0
  • +

Replies To: Undeclared Identifier and undefined class

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 13491
  • View blog
  • Posts: 53,889
  • Joined: 12-June 08

Re: Undeclared Identifier and undefined class

Posted 05 July 2016 - 06:56 PM

Why does your '.h' have a bunch of fleshed out methods in it?


Where is your reference/includes to the class 'products'?
21	            Products firstProduct(InitProDES);


Why does that line above not have a 'new'?
Was This Post Helpful? 0
  • +
  • -

#3 rubbaduckie0815  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 1
  • View blog
  • Posts: 26
  • Joined: 11-June 15

Re: Undeclared Identifier and undefined class

Posted 05 July 2016 - 08:23 PM

View Postmodi123_1, on 05 July 2016 - 06:56 PM, said:

Why does your '.h' have a bunch of fleshed out methods in it?


Where is your reference/includes to the class 'products'?
21	            Products firstProduct(InitProDES);


Why does that line above not have a 'new'?


I'm not sure which .h file your referring to, but I am trying to learn how to use GUI's and I decided to use a basic class setup to give my self some good ground before i got too in-depth with it. The form.h file seemed only necessary to show the system functions for the items I created.

I included stdafx.h in my member function cpp file. stdafx.h also includes .h file that has the references for the class.

I had tried using new, but still was no luck. I took it out before I created the thread and didn't think about adding it in.
Products firstProduct(InitProDES) = new Products(char []);


well it would have been nice if I had included the stdafx.h in my form.h
its compiling the class now. and the above declaration for the new would have been entirely wrrng anyways.

This post has been edited by rubbaduckie0815: 05 July 2016 - 08:52 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1