积极答复者
怎么调用实例化的类

问题
答案
-
您定义了一个结构体数组,然后可以对该数组的各个元素单独赋值(当然是对结构体的各个成员赋值)
例如类似这样:
typedef struct employee
{
employee() : email(""), number(0)
{}
string email;
int number;
}employee;
int main( void )
{
employee emclassemployee[10];
for(int i=0; i<10; i++)
{
emclassemployee[i].email = string("123456@htomail.com");
emclassemployee[i].number = i+1;printf("number: %02d, email: %s\n", emclassemployee[i].number, emclassemployee[i].email.c_str());
}
return 0;
}
Visual C++ enthusiast, like network programming and driver development. At present is being engaged in the WinCE/Windows Mobile platform embedded development.
楼主没有明白我的意思,我已经在类里面定义了结构体和实例化了,不是在MAIN里面定义和实例化的,而在另外的类里面怎么调用,这个问题的核心是怎么调用其他类里面已经实例化的对象- 已标记为答案 Honny_yeyh 2011年5月19日 12:31
全部回复
-
您定义了一个结构体数组,然后可以对该数组的各个元素单独赋值(当然是对结构体的各个成员赋值)
例如类似这样:
typedef struct employee
{
employee() : email(""), number(0)
{}
string email;
int number;
}employee;
int main( void )
{
employee emclassemployee[10];
for(int i=0; i<10; i++)
{
emclassemployee[i].email = string("123456@htomail.com");
emclassemployee[i].number = i+1;printf("number: %02d, email: %s\n", emclassemployee[i].number, emclassemployee[i].email.c_str());
}
return 0;
}
Visual C++ enthusiast, like network programming and driver development. At present is being engaged in the WinCE/Windows Mobile platform embedded development. -
您定义了一个结构体数组,然后可以对该数组的各个元素单独赋值(当然是对结构体的各个成员赋值)
例如类似这样:
typedef struct employee
{
employee() : email(""), number(0)
{}
string email;
int number;
}employee;
int main( void )
{
employee emclassemployee[10];
for(int i=0; i<10; i++)
{
emclassemployee[i].email = string("123456@htomail.com");
emclassemployee[i].number = i+1;printf("number: %02d, email: %s\n", emclassemployee[i].number, emclassemployee[i].email.c_str());
}
return 0;
}
Visual C++ enthusiast, like network programming and driver development. At present is being engaged in the WinCE/Windows Mobile platform embedded development.
楼主没有明白我的意思,我已经在类里面定义了结构体和实例化了,不是在MAIN里面定义和实例化的,而在另外的类里面怎么调用,这个问题的核心是怎么调用其他类里面已经实例化的对象- 已标记为答案 Honny_yeyh 2011年5月19日 12:31
-
struct employee
{
char name[30];
char zhiwei[40];
char id[30];
char mobile[30];
char phone[30];
char email[30];
};
employee emclassaemployee[26]=
{
{"Tia","Cl","E551","1....62","24...68","yua...@ex....com"},
{"Zha","Cl", "U114","13....13","24...36",fe..@m....m},
.........
};
在另外的函数体里面我要提出
emclassaemployee[i].email+",";
i++;
不知道怎么弄