ff.h
#pragma once
#ifndef ff_H_
#define ff_H_
class Plorg {
private:
char name[19];
int cl;
public:
Plorg(char p_name[19] = "Plorga", int n = 50);
void setcl(int n);
void showpl()const;
};
#endif
function.cpp
#include "ff.h"
#include <iostream>
using namespace std;
Plorg::Plorg(char p_name[19], int n)
{
strcpy(name, p_name);
cl = n;
}
void Plorg::setcl(int n)
{
cl = n;
}
void Plorg::showpl()const
{
cout << "Name :" << name<<endl
<< "CL :" << cl<<endl;
}
main.cpp
#include <iostream>
#include "ff.h"
#include <cstdlib>
using namespace std;
int main()
{
Plorg pl;
pl.showpl();
cout << "Please enter your name: ";
char name[19];
cin.getline(name, 19);
Plorg sl(name);
sl.showpl();
cout << "Please enter your CL: ";
int n = 0;
cin >> n;
sl.setcl(n);
sl.showpl();
system("pause");
return 0;
}