1道編程題,判斷一個單鏈表中是否存在環。
選擇題有一個typedef的題目以前沒有碰到過:
using namespace std;
typedef char * constchar;
void main(int argc, char *argv[])
{
char s[] = "asdf";
const constchar a = s;
*a = 'b';
cout << s;
}
說明const constchar與constchar const 是一樣的`,都是一個指向char的常指針
還有一個sizeof的
union u{
int a[4];
char b;
double c;
};
struct s{
int a;
u b;
};
void main(int argc, char *argv[])
{
cout << sizeof(s) << endl;
}
在vc上結果是24,在gcc上是20