Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdlib> // Standard General Utilities Library
- #include <cstdio> // Input/Output operations (C)
- #include <iostream> // Input/Output stream objects
- #include <fstream> // File input and output
- #include <ctime> // Date and time information
- #include <cmath> // Mathematical operations and transformations
- using namespace std;
- // Classes
- class opkontrolinis {
- private:
- int a, b;
- double c, d;
- public:
- opkontrolinis();
- opkontrolinis(int, int, double, double);
- void print();
- double suma();
- };
- // Methods
- opkontrolinis::opkontrolinis() {
- a = 1;
- b = 1;
- c = 1;
- d = 1;
- }
- opkontrolinis::opkontrolinis(int p1, int p2, double p3, double p4) {
- a = p1;
- b = p2;
- c = p3;
- d = p4;
- }
- void opkontrolinis::print() {
- cout << a << " " << b << " " << c << " " << d << endl;
- }
- double opkontrolinis::suma() {
- return a + b + c + d;
- }
- // Main program
- int main(int argc, char *argv[]) {
- opkontrolinis obj1;
- opkontrolinis obj2(5, 10, 15.5, 20.3);
- obj1.print();
- cout << "Suma = " << obj1.suma() << endl << endl;
- obj2.print();
- cout << "Suma = " << obj2.suma() << endl << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement