How to use this in class with C++

1 Answer

0 votes
#include <iostream>

class Example {
private:
    int x, y;
public:
     
    Example(int x, int y) {
        this->x = x;
        this->y = y;
    }
     
    void Print() const {
        std::cout << x << ", " << y << "\n";
    }
};
  
 
int main() {
    Example ex(234, 9870);
      
    ex.Print();
}
   
   
   
   
/*
run:
   
234, 9870
   
*/

 



answered Feb 4, 2023 by avibootz

Related questions

2 answers 174 views
174 views asked Mar 31, 2018 by avibootz
1 answer 155 views
2 answers 196 views
196 views asked Jul 5, 2017 by avibootz
1 answer 273 views
1 answer 159 views
1 answer 140 views
...