);
Application->CreateForm(__classid(TAboutBox), &AboutBox);
SplashForm->Hide();
SplashForm->Close();
Application->Run();
}
catch (Exception &exception)
{
Application->ShowException(&exception);
}
return 0;
}
指针
int array[] = { 2, 4, 6, 8, 10}
int myInteger = array[3]; // 值为 8
// ----使用指针可以实现同样的功能 -----
int array[] = { 2, 4, 6, 8, 10}
int* myPtr = array;
int myInteger = myPtr[3]; // 值为8
为指针解除引用
int x = 32;
int* ptr = &x;
//解除指针的引用
//以获得内存位置的内容
int y = *ptr; // y = 32
表的For循环
void TDataModuleEmployee::ListNames( TStrings *Items )
{
try
{
for ( TableAll->First(); !TableAll->Eof; TableAll->Next() )
if ( TableAll->FieldByName("Deleted")->AsBoolean == false )
Items->AddObject( TableAll->FieldByName("Name")->AsString, (TObject *)TableAll->FieldByName("Refnum")->AsInteger );
}
catch (Exception &e)
{
Application->ShowException(&e);
};
}
变量与常量的声明
char ch;
int count = 1;
char* name = "csdn.net";
struct complex { float my, his;};
float real(complex* p) {return p->my};
const double pi = 3.1415926535897932385;
templetate abc(T a) { return a < 0 ? -a : a; };
enum WebSite { one, two, three, four};
int* a; // * 指针
char* p[20]; // [ ] 数组
void myFunction(int); // ( )函数
struct str { short length; char* p; };
char ch1 = ''a'';
char* p = &ch1; // &引用 ,p保持着ch1的地址
char ch2 = *p; // ch2 = ''a''
检查表是否存在
#include "io.h"
if (access(Table1->TableName.c_str(),0)) //检查表是否存在
{ // 若不存在就创建 ...
Table1->Active = false;
Table1->TableType = ttParadox;
Table1->FieldDefs->Clear();
Table1->FieldDefs->Add("Myfield", ftString, 15, false);
Table1->IndexDefs->Clear();
Table1->CreateTable();
Table1->Active = true;
}
else
Table1->Active = true;
组件的类名
//找出丢失的组件类名
for(int i=0; i < ComponentCount; i++)
{
if(String(dynamic_cast<TComponent&>(*Components[i]).Name) == "")
{
ShowMessage(Components[i]->ClassName());
}
}
剪贴板中的文字
#include "memory.h" // 包含 auto_ptr<>
#include "clipbrd.hpp" //包含 TClipboard & Clipboard()
// 范例程序,包含了一个memo控件
__fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner)
{ //创建 TStringList对象
auto_ptr ClipText(new TStringList); //得到剪贴板中的文字的拷贝
ClipText->Text = Clipboard()->AsText; //然后加工一下...
Memo1->Lines->AddStrings(ClipText.get());
}
字符流
//范例一
#include "sstream"
const char *name = "cker";
const char *email = "cker@sina.com";
// 生成 "cker"[SMTP:cker@sina.com]
ostringstream ost;
ost << "\"" << name << "\"[SMTP:" << email << "]";
Edit1->Text = o
|