Created
November 4, 2014 01:19
-
-
Save werbet/605b61e2d22bf46d0bbb to your computer and use it in GitHub Desktop.
Aula de C++ - 03/11/2014
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdlib> | |
#include <iostream> | |
#include <string.h> | |
using namespace std; | |
class Aluno | |
{ | |
private: | |
char* nome; | |
char* curso; | |
public: | |
Aluno() | |
{ | |
} | |
Aluno(char* n, char* c) | |
{ | |
nome = new char[50]; | |
curso = new char[50]; | |
strcpy(curso, c); | |
strcpy(nome, n); | |
} | |
void imprime() | |
{ | |
printf("%s estuda %s!\n", nome, curso); | |
} | |
}; | |
class Lab | |
{ | |
private: | |
Aluno* alunos; | |
public: | |
Lab(Aluno* alunos_lab) | |
{ | |
alunos = alunos_lab; | |
} | |
}; | |
int main() | |
{ | |
char* nome; | |
char* curso; | |
Aluno* vetor; | |
int i; | |
int n; | |
int j; | |
printf("Digite a quantidade de alunos: \n"); | |
scanf("%d", &n); | |
vetor = new Aluno[n]; | |
for(i = 0; i < n; i++) | |
{ | |
nome = new char[10]; | |
printf("Digite o nome do aluno: \n"); | |
scanf("%s", nome); | |
curso = new char[10]; | |
printf("Digite o curso: \n"); | |
scanf("%s", curso); | |
vetor[i] = Aluno(nome, curso); | |
} | |
for(j = 0; j < n; j++) | |
vetor[j].imprime(); | |
Lab teste(vetor); | |
system("PAUSE"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment