Skip to content

Instantly share code, notes, and snippets.

@tornikegomareli
Created April 5, 2017 17:28
Show Gist options
  • Save tornikegomareli/646834387919a0d328fce18705e72f67 to your computer and use it in GitHub Desktop.
Save tornikegomareli/646834387919a0d328fce18705e72f67 to your computer and use it in GitHub Desktop.
OOP First Lesson _ Human Class Initialization #165
#include <iostream>
#include <string>
using namespace std;
struct Data
{
string Name;
string LastName;
int Age;
int Year;
string PrivateNumber;
string Hobbie;
};
class Human
{
private:
string Name;
string LastName;
int Age;
int Year;
string PrivateNumber;
string Hobbie;
public:
Human()
{
}
Human(Data * object)
{
this->Name = object->Name;
this->LastName = object->LastName;
this->Age = object->Age;
this->Year = object->Year;
this->PrivateNumber = object->PrivateNumber;
if (object->Hobbie == "Curva")
{
cout << " We cant Make Hobbie Curva " << endl;
}
else
this->Hobbie = object->Hobbie;
}
void Print()
{
cout << " Name : " << this->Name << endl;
cout << " LastName : " << this->LastName << endl;
cout << " Age : " << this->Age << endl;
cout << " Year : " << this->Year << endl;
cout << " PrivateNumber : " << this->PrivateNumber << endl;
cout << " Hobbie : " << this->Hobbie << endl;
}
};
void Initialize(Data * object)
{
cout << " Your Name : ";
cin >> object->Name;
cout << " Your LastName : ";
cin >> object->LastName;
cout << " Your Age : ";
cin >> object->Age;
cout << " Your birthday Year : ";
cin >> object->Year;
cout << " Your PrivateNumber : ";
cin >> object->PrivateNumber;
cout << " Your Hobbie : ";
cin >> object->Hobbie;
}
int main()
{
Data object;
Data * ob = &object;
Initialize(ob);
Human tornike(ob);
tornike.Print();
cin.get();
cin.get();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment