#include <algorithm>
#include <functional>
#include <iostream>
#include <iterator>
#include <numeric>
#include <vector>
class A
{
public :
int func( )
{
std:: cout << "in A's func " << std:: endl ;
return 1 ;
}
} ;
class B : public A
{
public :
bool func( )
{
std:: cout << "in B's func " << std:: endl ;
return true ;
}
} ;
int main( )
{
std:: vector < int > v( 10 , 2 ) ;
std:: partial_sum ( v.cbegin ( ) , v.cend ( ) , v.begin ( ) ) ;
std:: cout << "Among the numbers: " ;
std:: copy ( v.cbegin ( ) , v.cend ( ) , std:: ostream_iterator < int > ( std:: cout , " " ) ) ;
std:: cout << '\n ' ;
if ( std:: all_of ( v.cbegin ( ) , v.cend ( ) , [ ] ( int i) { return i % 2 == 0 ; } ) )
std:: cout << "All numbers are even\n " ;
std:: cout << "None of them are odd\n " ;
struct DivisibleBy
{
const int d;
DivisibleBy( int n) : d( n) { }
bool operator( ) ( int n) const { return n % d == 0 ; }
} ;
if ( std:: any_of ( v.cbegin ( ) , v.cend ( ) , DivisibleBy( 7 ) ) )
std:: cout << "At least one number is divisible by 7\n " ;
//A* a = new B();
//a->func();
B b;
int x = b.func ( ) ;
std:: cout << "x = " << x<< std:: endl ;
bool y = b.func ( ) ;
A a;
a.func ( ) ;
}
I2luY2x1ZGUgPGFsZ29yaXRobT4KI2luY2x1ZGUgPGZ1bmN0aW9uYWw+CiNpbmNsdWRlIDxpb3N0cmVhbT4KI2luY2x1ZGUgPGl0ZXJhdG9yPgojaW5jbHVkZSA8bnVtZXJpYz4KI2luY2x1ZGUgPHZlY3Rvcj4KIApjbGFzcyBBCnsKCXB1YmxpYzoKCWludCBmdW5jKCkKCXsKCQlzdGQ6OmNvdXQ8PCJpbiBBJ3MgZnVuYyAiPDxzdGQ6OmVuZGw7CgkJcmV0dXJuIDE7Cgl9Cn07CgpjbGFzcyBCIDogcHVibGljIEEKewoJcHVibGljOgoJYm9vbCBmdW5jKCkKCXsKCQlzdGQ6OmNvdXQ8PCJpbiBCJ3MgZnVuYyAiPDxzdGQ6OmVuZ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