[ create a new paste ] login | about

Link: http://codepad.org/3nwFbYe2    [ raw code | output | fork ]

C++, pasted on Jul 3:
//Файл document.h – базовый класс
#ifndef DOCUMENT_H
#define DOCUMENT_H
#include<iostream>
using namespace std;
class document
{
public:
document();
//document(string, int)
~document();
void SetName(string);
void SetNumber(int);
int GetName(string);
virtual void Show();
protected:
string Name;
int Number;
private:
};
#endif//DOCUMENT_H


//Файл document.cpp
#include<iostream>
#include"document.h"
using namespace std;
document::document()
//document::document (string m, int n)
//{Name="";
//Number=0;}
document::~document()
{}
void document::SetName(string m)
{Name=m;}
void document::SetNumber(int n)
{Number=n;}
void document::Show()
{cout<<"Фамилия: "<<Name<<"Номер: "<<Number<<endl;}
int document::GetName()
{return Name;}


//Файл pasport.h – класс-наследник
#ifndef PASPORT_H
#define PASPORT_H
#include<iostream>
#include"document.h"
using namespace std;
class pasport:public document
{
public:
pasport(string, int, string);
//~pasport();
void SetPol(string);
void Show();
protected:
private:
int Pol;
};
#endif//PASPORT_H


//Файл pasport.cpp
#include<iostream>
#include"pasport.h"
using namespace std;
pasport::pasport(string m, int n, string p)
{
Name=m);
Number=n;
Pol=p;
}
//pasport::~pasport
//{}
void pasport::SetPol(string p)
{Pol=p;}
void pasport::Show()
{cout<<"Фамилия: "<<Name<<"Номер: "<<Number<<"Пол: "<<Pol<<endl;}


//Файл studbilet.h ­ класс­-наследник
#ifndef STUDBILET_H
#define STUDBILET_H
#include"document.h"
#include<iostream>
using namespace std;
class studbilet:public document
{
public:
studbilet(string, int, string);
//~studbilet();
void SetForma(string);
void Show();
protected:
private:
string Forma;
};
#endif//STUDBILET_H


//Файл studbilet.cpp
#include<iostream>
#include"studbilet.h"
using namespace std;
studbilet::studbilet(string m, int n,string f)
{
Name=m;
Number=n;
Forma=f;
}
//studbilet::~studbilet()
//{};
void studbilet::SetForma(int f)
{Forma=f;}
void studbilet::Show()
{cout<<"Фамилия: "<<Name<<"Номер: "<<Number<<"Форма обучения: "<< Forma<<endl;}


//Файл main.cpp – главный модуль
#include<iostream>
#include"document.h"
#include"pasport.h"
#include"studbilet.h"
using namespace std;
int main()
{
pasport pt1("Иванов", 2238113644, "Муж");
pasport pt2("Лисицина", 1114993606, "Жен");
studbilet sb1("Лисицина", 2100187, "Очная");
studbilet sb2("Романов", 2344887, "Очная");
document*ps[4];
//Объединяем объекты разных типов в одном массиве
ps[0]=&pt1;
ps[1]=&pt2;
ps[2]=&sb1;
ps[3]=&sb2;
for(int i=0; i<4; i++)
ps[i]->Show();
//считаем
int k=0;
cout<<"\nВведите фамилию: "<<endl;
char a[50];
cin.GetLine (a,50);
for (int i = 0; i<4; i++)
{
if (ps[i]->GetName==a)
k++;}
cout<<”Количество документов на заданную фамилию: 
<<k<<endl;
}


Output:
1
2
3
4
5
6
7
Line 20: error: document.h: No such file or directory
Line 19: error: pasport.h: No such file or directory
Line 21: error: studbilet.h: No such file or directory
cc1plus: warnings being treated as errors
Line 128: warning: this decimal constant is unsigned only in ISO C90
Line 149: error: stray '\342' in program
compilation terminated due to -Wfatal-errors.


Create a new paste based on this one


Comments: