xxxxxxxxxx
#include <iostream>
using namespace std;
// Driver Code
int main()
{
// const int x; CTE error
// x = 9; CTE error
const int y = 10;
cout << y;
return 0;
}
xxxxxxxxxx
#include <iostream>
#include <string>
#include <type_traits>
void function ( int v = 0 ) ; // declaration (header)
// definition of void function ( int )
void function( const int v ) { std::cout << v << '\n' ; /* definition */ }
// *** error: redefinition of void function ( int )
// void function( int v ) { std::cout << v << '\n' ; /* definition */ }
// declaration and definition
void function_two( const int v ) { std::cout << v << '\n' ; /* definition */ }
int main()
{
function(7) ;
using function_type = void( int ) ;
function_type* fn = function ; // fine
fn = function_two ; // also fine note: const is ignored
using function_type_const = void( const int ) ; // note: const is ignored
function_type_const* fnconst = function ; // fine
fnconst = function_two ; // also fine
std::cout << std::boolalpha << "void(int) and void( const int ) are the same type: "
<< std::is_same< void(int), void( const int ) >::value << '\n' ; // true
}
xxxxxxxxxx
#include <iostream>
using namespace std;
#define PI 3.14159
#define NEWLINE '\n'
int main ()
{
double r=5.0; // radius
double circle;
circle = 2 * PI * r;
cout << circle;
cout << NEWLINE;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16