Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- using namespace std;
- class Ponto {
- // Access specifier
- public:
- // Coordenadas cartesianas
- float x = 0, y = 0;
- // Procedimentos seletores
- float& getX (){
- return x;
- }
- float& getY (){
- return y;
- }
- // Coordenadas polares:
- // arctan de (y/x)
- float getTeta (){
- return atan ((y/x));
- }
- // raiz de (x² + y²)
- float getR (){
- return sqrt(pow (x, 2) + pow (y, 2));
- }
- };
- int main() {
- cout<<"Abstrações procedimentais: procedimento seletor\n";
- // Declare an object of class pointer
- Ponto ponto;
- ponto.getX() = 1;
- ponto.getY() = 2;
- cout <<"X: " << ponto.getX() << "\n" <<
- "Y: " << ponto.getY() << "\n" <<
- "R: " << ponto.getR() << "\n" <<
- "Teta: " << ponto.getTeta();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement