Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

trouble adding a new header file

Status
Not open for further replies.

legos

Programmer
Jul 2, 2003
151
0
0
US
Hi everyone, I'm having some issues with a header file i want to add to my project. Here is the headerfile code.

#pragma once
using namespace System;

class Parser {
public:
Parser();
String^ parse(String^ equ)
{
String^ answer = "answer";
return answer;
}

};

I have #include "parser.h" in both my form.h file (the file that will use the parser class and in my stdafx.h file

Here is the code for my form1.h file

#pragma once
#include "parser.h"

namespace Calc {

using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
}

protected:
~Form1()
{
if (components)
{
delete components;
}
}
private:
// Win controls, Icon & Menu
TextBox^ CalcField;
ListBox^ CalcScreen;
array<Button^>^ CalcButtons;
static String^ s_strZero;
System::ComponentModel::Container ^components;

#pragma region Windows Form Designer generated code

void InitializeComponent(void){//call to calcEqual_Click}

void CalcEqual_Click(Object^ sender, EventArgs^)
{
String^ strValue = CalcField->Text;
if (strValue->Length != 0)
{
CalcScreen->Items->Add(strValue);
CalcField->Text = s_strZero;
Parser newparser();
CalcScreen->Items->Add(newparser.parse(strValue));
}
}
#pragma endregion
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {}
};
}


The error that I am getting is "left of '.parse' must have class/struct/union"
which happens on the line that says
CalcScreen->Items->Add(newparser.parse(strValue));


Durible Outer Casing to Prevent Fall-Apart
 
What are all those ^ characters in your code? I've never seen any code like that.
 
I based the code off some code samples from MSDN, but it was a .Net 2002 program that was converted to 2005 so that may be why.

I found the solution to the problem, You need to include this line at the top of your form1.h file

#pragma once
#include "parser.h"
#include <vcclr.h>

Durible Outer Casing to Prevent Fall-Apart
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top