literal
this
:: name
name
( expression )
// expre_Primary_Expressions.cpp
// compile with: /LD
class Example
{
public:
void Func(); // * const this
void Func() const; // const * const this
void Func() volatile; // volatile * const this
};
100 // literal 'c' // literal this // in a member function, a pointer to the class instance ::func // a global function ::operator + // a global operator function ::A::B // a global qualified name ( i + 1 ) // a parenthesized expression
MyClass // a identifier MyClass::f // a qualified name operator = // an operator function name operator char* // a conversion operator function name ~MyClass // a destructor name A::B // a qualified name A<int> // a template id
primary-expression
postfix-expression [ expression ]
postfix-expression ( expression-list)
simple-type-name ( expression-list)
postfix-expression . name
postfix-expression –> name
postfix-expression ++
postfix-expression ––
cast-keyword < typename > (expression )
typeid ( typename )
void Func( int i ); // Function prototype ... Func( 7 ); // Execute function call
int Temp_i = 7; Func( Temp_i );
// expre_Formal_and_Actual_Arguments.cpp
void func( long param1, double param2 );
int main()
{
long i = 1;
double j = 2;
// Call func with actual arguments i and j.
func( i, j );
}
// Define func with formal parameters param1 and param2.
void func( long param1, double param2 )
{
}
// expre_Treatment_of_Argument_Types.cpp
int func1( const int i, int j, char *c ) {
i = 7; // C3892 i is const.
j = i; // value of j is lost at return
*c = 'a' + j; // changes value of c in calling function
return i;
}
double& func2( double& d, const char *c ) {
d = 14.387; // changes value of d in calling function.
*c = 'a'; // C3892 c is a pointer to a const object.
return d;
}
// expre_Ellipses_and_Default_Arguments.cpp
// compile with: /EHsc
#include <iostream>
// Declare the function print that prints a string,
// then a terminator.
void print( const char *string,
const char *terminator = "\n" );
int main()
{
print( "hello," );
print( "world!" );
print( "good morning", ", " );
print( "sunshine." );
}
using namespace std;
// Define print.
void print( const char *string, const char *terminator )
{
if( string != NULL )
cout << string;
if( terminator != NULL )
cout << terminator;
}
hello, world! good morning, sunshine.
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有