Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<vector>
- #include<string>
- #include<iterator>
- #include<algorithm>
- using namespace std;
- class Aluno{
- private:
- string nome;
- int codigo;
- public:
- Aluno(string nome, int codigo)
- {
- this->nome = nome;
- if(codigo < 0)
- {
- throw "valor invalido";
- }
- this->codigo = codigo;
- }
- Aluno()
- {
- }
- string getNome()
- {
- return(nome);
- }
- void setNome(string nome)
- {
- this->nome = nome;
- }
- int getCodigo()
- {
- return(codigo);
- }
- void setCodigo(int codigo)
- {
- this->codigo = codigo;
- }
- };
- int main()
- {
- int nota;
- cin >> nota;
- try
- {
- Aluno a("maria", nota);
- cout << a.getCodigo() << endl;
- if(nota - nota == 0)
- {
- throw "divisao por zero";
- }
- }
- catch(const char* msg)
- {
- cout << msg << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement