cºÍc++ÖеÄconstµÄÇø±ð
ÏÈ¿´Ò»¸ö³ÌÐò
#include <stdio.h>
int main()
{
const int a = 5;
int b[a];
return 0;
}
ÔÚvc6.0ÖÐÃüÃûΪ.cÎļþ£¬±àÒë»á³ö´í£¬ÊÇint b[a]ÕâÒ»ÐУºexpected constant expression
ÃüÃûΪ.cppÎļþ£¬Ã»ÎÊÌâ¡£
ÔÚcodeblocks(Ò»¸öÃâ·Ñ¿ªÔ´µÄ±àÒëÆ÷)ÖбàÒ붼ûÎÊÌâ
»¹ÓÐÒ»¸ö³ÌÐò
#include <stdio.h>
int main()
{
const int a = 5;
int b = 4;
switch (b)
{
case 3:
case a:
case 4:
printf("asdf");
break;
}
return 0;
}
ÔÚvc6.0ÖÐÃüÃûΪ.cÎļþ£¬±àÒë»á³ö´í£¬ÊÇcase a:ÕâÒ»ÐУºcase expression not constant
ÃüÃûΪ.cppÎļþ£¬Ã»ÎÊÌâ¡£
ÔÚcodeblocksÖÐн¨c¹¤³ÌÎļþ±àÒë»á³ö´í£¬Ð½¨c++¹¤³ÌÎļþ²»»á³ö´í¡£
´ÓÉÏÃæÁ½¸öÀý×ÓÊDz»ÊÇ˵ÔÚcÖÐÓÃconst¶¨ÒåµÄaÊÇÒ»¸öÖ»¶ÁµÄ±äÁ¿£¬¶øÔÚc++ÖÐÓÃconst¶¨ÒåµÄa±»µ±³ÉÒ»¸ö³£Á¿ÁË£¿
Chiyer¡¿:
constÊÇÒ»¸öCÓïÑԵĹؼü×Ö£¬ËüÏÞ¶¨Ò»¸ö±äÁ¿²»ÔÊÐí±»¸Ä±ä¡£Ê¹ÓÃconstÔÚÒ»¶¨³Ì¶ÈÉÏ¿ÉÒÔÌá¸ß³ÌÐòµÄ½¡×³ÐÔ£¬ÁíÍ⣬ÔÚ¹Û¿´±ðÈË´úÂëµÄʱºò£¬ÇåÎúÀí½âconstËùÆðµÄ×÷Ó㬶ÔÀí½â¶Ô·½µÄ³ÌÐòÒ²ÓÐһЩ°ïÖú¡£
ËäÈ»ÕâÌýÆðÀ´ºÜ¼òµ¥£¬µ«Êµ¼ÊÉÏ£¬constµÄʹÓÃÒ²ÊÇcÓïÑÔÖÐÒ»¸ö±È½Ï΢ÃîµÄµØ·½£¬Î¢ÃîÔںδ¦ÄØ£¿Çë¿´ÏÂÃ漸¸öÎÊÌâ¡£
¡¡¡¡ÎÊÌ⣺const±äÁ¿ & ³£Á¿
¡¡¡¡ÎªÊ²Ã´
Ïà¹ØÎÊ´ð£º
QQȺ 29152388
ÓÑÇéUP
°ï¶¥
up
°ïup
up Ö§³Ö£¡
up jf
...ÄѵÀÓзÖ..?
up up up
Ï£ÍûÓеüӷ֣¬¹þ¹þ¡£
Ö§³Ö£¬ÎÒ¼ÓÁË£¬Ï£ÍûÂ¥Ö÷ÄܼÓÎÒ£¬¹²Í¬Ñ§Ï°¹þ
¼ÓÁË¡£
¶¥ÉÏ£¬Ã¿ÌìÊÕ»ñÒ»µã£¬Ö§³Ö ......
Ä¿Ç°Óöµ½µÄÎÊÌâÊÇ£º
´æ·ÅÔÚÔ¶³Ì·þÎñÆ÷¶Ëc/s³ÌÐòÒ»ÓиüУ¬ÈçºÎ×öµ½¿Í»§¶ËÁ¢¼´ÏìÓ¦µ¯³öÓÐ×îÐÂÉý¼¶µÄÌáʾ´°¿Ú¡£
±¾À´Óеã˼·£º²ÉÓÃWCF+windowns·þÎñ+¶¨Ê±Æ÷µÄ·½Ê½Ò²ÄÜʵÏÖ£¬µ«ÊÇÿ̨¿Í»§¶Ë»ú×Óÿ¸ô¶¼È¥·ÃÎÊÒ»ÏÂÔ¶³Ì ......
ÇëÎʸ÷λ¸ßÊÖÈçºÎÓÃC/C++»ñµÃϵͳδ°²×°²¹¶¡
ºÃÏñºÜרҵµÄ¶«Î÷¡£¡£¡£
²é×¢²á±í
ÿ¸ö²¹¶¡Èç¹û°²×°Á˶¼»áÔÚ×¢²á±íÀïÃæµÇ¼Ç
ÇëÎÊÄܲ»ÄܸüÇåÎúЩ£¬ÎÒÏëÓÃc\c++²é³öÀ´£¬²»ºÃÒâ˼£¬ÎÒÊÇÐÂÊÖ¡£»¹ÍûÖ¸½Ì¡£Ð»
·ÖÖµ ......
ÎÊÌâ:¹¤µØÉÏÐèÒª³¤¶ÈΪA1µÄ¸Ö½îX¸ù,³¤¶ÈΪA2µÄ¸Ö½îY¸ù,³¤¶ÈΪA3µÄ¸Ö½îZ¸ù......ÒÔ´ÎÀàÍÆ.
ÆäÖÐA1,A2,A3,...³¤¶ÈÈÎÒâÖ¸¶¨,X,Y,Z,...ÊýÁ¿Ò²ÈÎÒâÖ¸¶¨.
µ«²Ö¿âÖеĸֽîΪ±ê×¼³¤¶È,Ö»ÓÐ9Ã׺Í15Ã×Á½ÖÖ³¤¶È,ÊýÁ¿² ......