i have windows form app 2 text box1,2 2 button1,2 i have class person {have get, set (string ,int)} and i want to declare person p; to see it in both two push button1,2
my problem is i declare person p; inside buttons when buttons end p.~person();is called so i cant save value
and when i call p.get i get initial value
code
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)
{person p;
//string str;
stringstr(constchar*)System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi(textBox1->Text).ToPointer();
p.set( str,int ::Parse(textBox2->Text));
private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e)
{person p;
string str;
int ag;
p.get(str,ag);
i declare class as
class person
{
public:
person();// create initial value
~person();//descon
void set(string z,int a);//set value
void get(string &z,int &a);//get value
private:
string name;
int age ;
};
------------------------------------------------------------
person cpp
#include "StdAfx.h"
#include "person.h"
#include "stdafx.h"
using namespace std;
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
person::person()
{name="null";
age=-1;
}
person::~person()
{
}
void person::set(string z, int a)
{name=z;
age= a;
}
void person::get(string &z, int &a)
{z =name;
a=age;
}
can i upload all solution or not?