Code class in a separate file:
template <class mainType> class MY
{
private:
System::Int64 start,end,max;
mainType *mT;
public:
MY(System::Int64 value)
{
mT=new mainType[max+1];
start=0;
end=0;
max=value;
}
System::Boolean is_Empty()
{
if(start==end)
return true;
else
return false;
}
System::Int64 order(mainType &value)
{
if(start==end)
return -1;
value=mT[start++];
if(start>max)
start=0;
return 1;
}
System::Void insert(mainType value)
{
mT[end++]=value;
if(end>max)
end=0;
}
};
Main program:
#pragma endregion
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {
}
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
char **tables,*WWW;
tables=new char*[10];
System::Int64 i;
System::Int64 temp_Bool;
for(i=0;i<10;i++)
tables[i]=new char[20];
tables[0]="www.hpe.com";
tables[1]="www.ibm.com";
tables[2]="www.google.com";
tables[3]="www.cnn.com";
tables[4]="www.yahoo.com";
tables[5]="www.nasa.org";
tables[6]="www.microsoft.com";
tables[7]="www.linux.com";
tables[8]="www.embarcadero.com";
tables[9]="www.java.com";
array<System::String^>^ string_Tables=gcnew array<System::String^>(10);
MY<char*> FIFO_values(11);
dataGridView1->ColumnCount=1;
dataGridView1->RowCount=10;
for(i=0;i<10;i++)
{
FIFO_values.insert(tables[i]);
System::String^ temp=gcnew System::String(tables[i]);
dataGridView1->Rows[i]->Cells[0]->Value=temp;
}
for(i=0;i<11;i++)
{
temp_Bool=FIFO_values.order(WWW);
if(temp_Bool==true)
{
System::String^ temp=gcnew System::String(WWW);
listBox1->Items->Add("You can use - "+temp);
}
}
for(i=0;i<10;i++)
delete [] tables[i];
delete [] *tables;
}
private: System::Void dataGridView1_CellContentClick(System::Object^ sender, System::Windows::Forms::DataGridViewCellEventArgs^ e) {
System::String^ myWWW;
myWWW="http:/";
myWWW=safe_cast<DataGridView^>(sender)->CurrentCell->Value->ToString();
System::Diagnostics::Process::Start(myWWW);
}
};
}
I tried to use the structure - array<System::String^>^ tables=gcnew array<System::String^>(10),but for costructor class (new[max+1]) type String^ and array showed errors. So i used - char*.
Brak komentarzy:
Prześlij komentarz