Skip to content

Instantly share code, notes, and snippets.

@Luccasoli
Created April 24, 2018 01:27
Show Gist options
  • Save Luccasoli/90a5aa1ccbc35ef855a4d45c781b18c6 to your computer and use it in GitHub Desktop.
Save Luccasoli/90a5aa1ccbc35ef855a4d45c781b18c6 to your computer and use it in GitHub Desktop.
Classe Numero e seu makefile
CXX = g++
CXXFLAGS = -Wall -g
main: main.o Numero.o
$(CXX) $(CXXFLAGS) -o main main.o Numero.o
main.o: main.cpp Numero.o
$(CXX) $(CXXFLAGS) -c main.cpp
Numero.o: Numero.h
#include "Numero.h"
#include <bits/stdc++.h>
void Numero::gera_num(){
std::srand(std::time(0));
valor = rand() % 10000 + 1;
}
int Numero::somatorio(){
int soma = 0;
for (int i = 1; i <= valor; ++i)
{
soma += i;
}
return soma;
}
Numero::Numero(){
Numero::gera_num();
}
#include <bits/stdc++.h>
class Numero{
public:
int valor;
void gera_num();
int somatorio();
Numero();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment