1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
#include <iostream>
namespace jor_tad
{
class lock
{
public:
lock( int x = 0, int y = 0, int z = 0 ) : x(x), y(y), z(z) {}
// ...
private:
int x, y, z;
};
void set_combination( lock& lk ) // non-member function
{
int x, y, z ;
std::cout << "please enter your three numbers:\n" ;
std::cin >> x >> y >> z ;
lk = { x, y, z } ; // x, y and z: C+11
// lk = lock(x,y,z) ; // set x, y ans z legacy C++
}
}
int main()
{
jor_tad::lock lk ;
set_combination(lk) ; // ADL (argument dependant lookup aka koenig lookup)
// finds jor_tad::set_combination
}
|