.


:




:

































 

 

 

 


A. AC x = 1 y = 1.73205




x = 1

y = 1

AC x = 1 y = 1.73205

C x = 2 y = 2.73205

. . . .

, : Vec AC ("AC") AC (AB, 60). , .

. . : , . . :

operator <__> ();

:

ü ;

ü ;

ü , operator;

ü ;

ü .

:

Vec.h

class Vec //

{

public:

Vec operator * (double m); //

Vec operator / (double d); //

operator double (); //

};

Vec.cpp

#include "Vec.h"

Vec Vec:: operator * (double m) //

{

Vec T ("T", x * m, y * m); //

return T; //

}

Vec Vec::operator / (double d) //

{

Vec T ("T", x / d, y / d); //

return T; //

}

Vec::operator double () //

{

return sqrt (x*x + y*y); //

}

Main.cpp

#include "Vec.h"

Void main ()

{

char S [ ] = " ";

CharToOem (S, S);

Vec V ("V", 1, 1),W ("W"), N ("N"); //

~ (N = V / V); // ,

// ,

// .

cout << S << "N =\t" << (double) N << '\n'; //

~ (W = N * 2.0); // W, 2,

// W.

cout << S << "W =\t" << (double) W << '\n';

}

. , . .

cout << (double) N << '\n' .

~ (N = V / V) , . . Vec . Vec , , V / V V / (double) V.

:

N x = 0.707107 y = 0.707107

N = 1

W x = 1.41421 y = 1.41421

W = 2





:


: 2016-11-23; !; : 417 |


:

:

.
==> ...

1631 - | 1566 -


© 2015-2024 lektsii.org - -

: 0.011 .