Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

C/C++ÖеĽṹÌå(struct)


ʲôÊǽṹÌ壿
¼òµ¥µÄÀ´Ëµ£¬½á¹¹Ìå¾ÍÊÇÒ»¸ö¿ÉÒÔ°üº¬²»Í¬Êý¾ÝÀàÐ͵ÄÒ»¸ö½á¹¹£¬ËüÊÇÒ»ÖÖ¿ÉÒÔ×Ô¼º¶¨ÒåµÄÊý¾ÝÀàÐÍ£¬ËüµÄÌصãºÍÊý×éÖ÷ÒªÓÐ
Á½µã²»Í¬£¬Ê×ÏȽṹÌå¿ÉÒÔ
ÔÚÒ»¸ö½á¹¹ÖÐÉùÃ÷²»Í¬µÄÊý¾ÝÀàÐÍ£¬µÚ¶þÏàͬ½á¹¹µÄ½á¹¹Ìå±äÁ¿ÊÇ¿ÉÒÔÏ໥¸³ÖµµÄ£¬¶øÊý×éÊÇ×ö²»µ½µÄ£¬ÒòΪÊý×éÊǵ¥Ò»Êý¾ÝÀàÐ͵ÄÊý¾Ý¼¯ºÏ£¬Ëü±¾Éí²»ÊÇÊý¾ÝÀàÐÍ
(¶ø½á¹¹ÌåÊÇ)£¬Êý×éÃû³ÆÊdz£Á¿Ö¸Õ룬ËùÒÔ²»¿ÉÒÔ×öΪ×óÖµ½øÐÐÔËË㣬ËùÒÔÊý×éÖ®¼ä¾Í²»ÄÜͨ¹ýÊý×éÃû³ÆÏ໥¸´ÖÆÁË£¬¼´Ê¹Êý¾ÝÀàÐͺÍÊý×é´óСÍêÈ«Ïàͬ¡£
¶¨Òå½á¹¹ÌåʹÓÃstructÐÞÊηû£¬ÀýÈ磺
struct test
{
float a;
int b;
};
ÉÏÃæµÄ´úÂë¾Í¶¨ÒåÁËÒ»¸öÃûΪtestµÄ½á¹¹Ì壬ËüµÄÊý¾ÝÀàÐ;ÍÊÇtest£¬Ëü°üº¬Á½¸ö³ÉÔ±aºÍb£¬³ÉÔ±aµÄÊý¾ÝÀàÐÍΪ¸¡µãÐÍ£¬³ÉÔ±bµÄÊý¾ÝÀàÐÍΪÕûÐÍ¡£
ÓÉÓڽṹÌå±¾Éí¾ÍÊÇ×Ô¶¨ÒåµÄÊý¾ÝÀàÐÍ£¬¶¨Òå½á¹¹Ìå±äÁ¿µÄ·½·¨ºÍ¶¨ÒåÆÕͨ±äÁ¿µÄ·½·¨Ò»Ñù¡£
test pn1;
ÕâÑù¾Í¶¨ÒåÁËÒ»test½á¹¹ÌåÊý¾ÝÀàÐ͵ĽṹÌå±äÁ¿pn1£¬½á¹¹Ìå³ÉÔ±µÄ·ÃÎÊͨ¹ýµã²Ù×÷·û½øÐУ¬pn1.a=10 ¾Í¶Ô½á¹¹Ìå±äÁ¿pn1µÄ³ÉÔ±a½øÐÐÁ˸³Öµ²Ù×÷¡£
×¢Òâ:½á¹¹ÌåÉúÃüµÄʱºò±¾Éí²»Õ¼ÓÃÈκÎÄÚ´æ¿Õ¼ä£¬Ö»Óе±ÄãÓÃÄ㶨ÒåµÄ½á¹¹ÌåÀàÐͶ¨Òå½á¹¹Ìå±äÁ¿µÄʱºò¼ÆËã»ú²Å»á·ÖÅäÄÚ´æ¡£
½á¹¹Ì壬ͬÑùÊÇ¿ÉÒÔ¶¨ÒåÖ¸ÕëµÄ£¬ÄÇô½á¹¹ÌåÖ¸Õë¾Í½Ð×ö½á¹¹Ö¸Õë¡£
½á¹¹Ö¸Õëͨ¹ý->·ûºÅÀ´·ÃÎʳÉÔ±£¬ÏÂÃæÎÒÃǾÍÒÔÉÏËù˵µÄ¿´Ò»¸öÍêÕûµÄÀý×Ó£º
#include <iostream>
#include <string>
using namespace std;
struct test//¶¨ÒåÒ»¸öÃûΪtestµÄ½á¹¹Ìå
{
int a;//¶¨Òå½á¹¹Ìå³ÉÔ±a
int b;//¶¨Òå½á¹¹Ìå³ÉÔ±b
};
void main()
{
test pn1;//¶¨Òå½á¹¹Ìå±äÁ¿pn1
test pn2;//¶¨Òå½á¹¹Ìå±äÁ¿pn2
pn2.a=10;//ͨ¹ý³ÉÔ±²Ù×÷·û.¸ø½á¹¹Ìå±äÁ¿pn2ÖеijÉÔ±a¸³Öµ
pn2.b=3;//ͨ¹ý³ÉÔ±²Ù×÷·û.¸ø½á¹¹Ìå±äÁ¿pn2ÖеijÉÔ±b¸³Öµ
pn1=pn2;//°Ñpn2ÖÐËùÓеijÉÔ±Öµ¸´ÖƸø¾ßÓÐÏàͬ½á¹¹µÄ½á¹¹Ìå±äÁ¿pn1
cout<<pn1.a<<"|"<<pn1.b<<endl;
cout<<pn2.a<<"|"<<pn2.b<<endl;
test *point;//¶¨Òå½á¹¹Ö¸Õë
point=&pn2;//Ö¸ÕëÖ¸Ïò½á¹¹Ìå±äÁ¿pn2µÄÄÚ´æµØÖ·
cout<<pn2.a<<"|"<<pn2.b<<endl;
point->a=99;//ͨ¹ý½á¹¹Ö¸ÕëÐ޸ĽṹÌå±äÁ¿pn2³ÉÔ±aµÄÖµ
cout<<pn2.a<<"|"<<pn2.b<<endl;
cout<<point->a<<"|"<<poi


Ïà¹ØÎĵµ£º

º½¿Õ¹«Ë¾¹ÜÀíϵͳ(VC++ ÓëSQL 2005)

ϵͳ»·¾³£ºWindows 7
Èí¼þ»·¾³£ºVisual C++ 2008 SP1 +SQL Server 2005
±¾´ÎÄ¿µÄ£º±àдһ¸öº½¿Õ¹ÜÀíϵͳ
      ÕâÊÇÊý¾Ý¿â¿Î³ÌÉè¼ÆµÄ³É¹û£¬ËäÈ»³É¼¨²»¼Ñ£¬µ«ÊÇ×÷ΪÎÒÓÃVC++ ÒÔÀ´±àдµÄ×î´ó³ÌÐò»¹ÊÇ´«µ½ÍøÉÏ£¬ÒÔ¹©²Î¿¼¡£ÓÃVC++ ×öÊý¾Ý¿âÉè¼Æ²¢²»ÈÝÒ×£¬µ«Ò²²»ÊDz»¿ÉÄÜ¡£ÒÔÏÂÊÇÎҵijÌÐò½çÃ棬ºóÃæ ......

Pro*C ²¢·¢Êý¾Ý¿âÁ¬½Ó¡¢½¨Á¢Êý¾Ý¿âÁ´

/*
 *  ¸Ã¹¦ÄÜÖ÷ÒªÊÇÑÝʾ£¬Í¬Ê±Á¬½ÓÁ½¸ö²¢·¢µÄÊý¾Ý¿â
 */
/* °üº¬CÍ·Îļþ */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
/* °üº¬SQLCAÍ·Îļþ */
EXEC SQL INCLUDE sqlca;
EXEC SQL INCLUDE sqlda;
int main()
{
    EXEC SQL BEGIN DE ......

C´úÂë¹æ·¶ÓëÔËÐÐʱ³¤·ÖÎöÄ£°å

/*****************************************************
Îļþ:main.c
¹¦ÄÜ:²âÊÔÔËÐÐʱ¼ä(C)!
×÷Õß:chinayaosir   QQ:44633197
¹¤¾ß:VC++6.0±àÒëOK!
ÈÕÆÚ:11/28/2009
´úÂëĿ¼:
//1.°üº¬Í·Îļþ
//2.mainÖ÷³ÌÐò
//²»Í¬µÄË㷨ʵÏÖµÄÐÔÄÜ,ÔËÐÐʱ¼äÏà²î·Ç³£´óµÄ!
ÐÞ¸ÄÁбí:
***************** ......

CºÍÖ¸Õëѧϰ±Ê¼Ç £¨1£©

CºÍÖ¸Õëѧϰ±Ê¼Ç £¨1£©
       µÚ¶þÕ »ù±¾ÖªÊ¶
»·¾³£º·ÖΪ·­ÒëºÍÖ´ÐÐ2¸ö¹ý³Ì¡£ÆäÖз­Òë¿ÉÒÔÀí½âΪÊÇÒ»¸ö´Ó³ÌÐò—Ä¿±ê´úÂë—Á´½ÓÆ÷µÄ¹ý³Ì¡£±àÒë¹ý³ÌÓУº
1Ô¤´¦ÀíÆ÷£º´¦Àí#define #includeÕâÒ»Àà´úÂëµÄ¹ý³Ì£»
2Ô´´úÂë½âÎö£º²úÉú´íÎóºÍ¾¯¸æ£»
3ÓÅ»¯Æ÷£ºÓÐÀûÓÚÓÅ»¯´úÂ룬Ìá¸ßЧ ......

ÔÚWindowsÏÂÉèÖÃNetBeansµÄC/C++»·¾³

NetBeansÌṩÁËÒ»¸öºÜºÃµÄC/C++¿ª·¢»·¾³£¬Õâ¸ö¿ª·¢»·¾³ÊÇ»ùÓÚGCC±àÒëÆ÷£¬ËùÒÔÔÚWindowsÉÏÊÇÐèҪͨ¹ýÅäÖòÅÄÜʹÓÃNetBeansµÄC/C++ƽ̨¡£
ÅäÖÃÖ»ÓÐÈý²½£º
1¡¢ÏÂÔØMinGWºÍMSYS
2¡¢ÅäÖÃMSYSµÄ»·¾³±äÁ¿
3¡¢ÔÚNetBeansÖÐÅäÖÃC/C++ƽ̨
-------------------------
µÚÒ»²½£ºÏÂÔØMinGWºÍMSYS
Ê×ÏÈÐèÒªÏÂÔØMinGWºÍMSYS£¬MinGWÊ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ