Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Main
- #include <iostream>
- // include header mora ici sa ""
- #include "Complex.h"
- using namespace std;
- /**< default vrijednost je nasumicna */
- /**< cout - posetak stampe, endl - novi red */
- /**< sve dok je dvotacka prenosi se pravo pristupa (najcesce sa pise sa sekcijama) */
- int main()
- {
- Complex c1;
- /**< ovdje, klasa se ne smatra varijablom nego objektom */
- c1.SetData(32,10);
- c1.PrintFunkcija();
- cout << c1.Abs()<< endl;
- return 0;
- }
- //Header
- class Complex
- {
- private:
- float real;
- float img;
- public:
- void PrintFunkcija();
- void SetData(float r, float i);
- float Abs();
- };
- //Klasa
- #include "Complex.h"
- #include <math.h>
- #include "iostream"
- using namespace std;
- void Complex::PrintFunkcija()
- {
- cout << "Podaci " << real << " " << img << endl;
- }
- void Complex::SetData( float r, float i)
- {
- real=r;
- img=i;
- }
- float Complex::Abs()
- {
- return sqrt(real*real + img*img);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement