>1. unsigned x // is it legal ?
Yes. An unadorned "unsigned" is taken to mean unsigned int. Though if you need an unsigned short or long then you must say so explicitly.
>2. sizeof x // is it legal ?
Yes, provided that x is not a type name. If the operand to sizeof is a "thing" then you can omit the parentheses, but if the operand is a type you must use them:
Code:
int x;
sizeof ( x ); // Legal
sizeof x; // Also legal
sizeof ( int ); // Legal
sizeof int; // Not legal
>return ; // is it legal ?
Yes, provided that the function was declared to return void. It is equivalent to falling off the end of the function. The two following functions perform the same way:
Code:
void foo()
{
return;
}
void bar()
{
}
>but if you are writnig a func it is bound to return something. this is a function rule.
C++ makes no distinction between functions and subroutines. A C++ function performs both jobs:
Code:
void subroutine ( int x )
{
cout<< x <<endl;
}
int function ( int x )
{
cout<< x <<endl;
return x;
}