Quick actions

cmd+k|ctrl+k

Navigation

Languages

Lab 06.1

Snippet info

Language

Cpp

Visibility

public

Author

gabriel.felipe8

Created

2022-09-09T22:24:35.345596Z

Updated

2022-09-09T22:24:35.345596Z

#include <iostream>
using namespace std;

class Somatorio{
   public:
    int x;
    int soma = 0;

     Somatorio (int y){
          for (x = 0; x <= y; x++){
           
            soma += x;
          }
    }
    
    void setSomatorio(int soma){
        soma = 0;
    }
    
    int getSomatorio(){
        return soma;
    }
       
    };
        

int main() {
    Somatorio obj(5);
    obj.setSomatorio(10);
    
    cout << obj.getSomatorio() << "\n";
    return 0;
}
INFO