Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- template<typename T>
- class Curve
- {
- private:
- T x, y, y1;
- public:
- Curve(T x) {
- y = x*x+2;
- y1 = x - 2;
- }
- const T operator+(const Curve& a) const {
- return y + a.y1;
- }
- const T operator-(const Curve& a) const {
- return y- a.y1;
- }
- const T operator*(const T& a) const {
- return (y*a);
- }
- T operator()(T x) {
- return y;
- }
- T getY(){
- return y;
- }
- };
- int main()
- {
- Curve<double> c1(6.0);
- Curve<double> c2(4.0);
- std::cout <<c1.getY() <<std::endl;
- std::cout <<c2.getY() << std::endl;
- std::cout <<(c2 - c1) <<std::endl;
- std::cout <<(c1*4.0) << std::endl;
- std::cout << c1(4.0) << std::endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement