결국 뭐 좀 해볼려고 하면, 결국에는 포인터로 귀결이 되는구나.

 

/*
    CPointer2.cpp
*/

#include <iostream>
#include <string.h>

using std::cout;
using std::endl;

class Person
{
public :
    void Sleep()
    {
        cout<<"Sleep"<<endl;
    }
};

class Student : public Peson
{
public :
    void Study()
    {
        cout<<"Study"<<endl;
    }
};

class PartTimeStd : public Student
{
public :
    void Work()
    {
        cout<<"Work"<<endl;
    }
};

int main(void)
{
    Person* p3 = new PartTimeStd;

    p3->Sleep();

    return 0;
}

반응형

'C, C++, Java' 카테고리의 다른 글

CReference2.cpp  (0) 2014.05.02
P304.cpp  (0) 2014.05.02
EmployeeManager3.cpp  (0) 2014.05.02
Person.cpp  (0) 2014.04.30
P256.cpp  (0) 2014.04.30

/*
 EmployeeManager3.cpp
*/

#include <iostream>
#include <string.h>

using std::cout;
using std::endl;

/*=======================================*/
/*           */
/*    Employee Class    */
/*           */
/*=======================================*/

class Employee
{
protected :
    char name[20];

public :
    Employee(const char* _name);
    const char* GetName() const;
};

Employee::Employee(const char* _name)
{
    strcpy(name, _name);
}

const char* Employee::GetName() const
{
    return name;
}


/*=======================================*/
/*           */
/*        Permanent Class           */
/*           */
/*=======================================*/

class Permanent : public Employee
{
private :
    int salary;

public :
    Permanent(const char* _name, int sal);
    int GetPay() const;
};

Permanent::Permanent(const char* _name, int sal) : Employee(_name)
{
    salary = sal;
}

int Permanent::GetPay() const
{
    return salary;
}

/*=======================================*/
/*           */
/*        Temporary Class            */
/*           */
/*=======================================*/
class Temporary : public Employee
{
private :
    int time;
    int pay;

public :
    Temporary(const char* _name, int _time, int _pay);
    int GetPay() const;
};

Temporary::Temporary(const char *_name, int _time, int _pay) : Employee(_name)
{
    time = _time;
    pay  = _pay;
}

int Temporary::GetPay() const
{
    return time * pay;
}

/*=======================================*/
/*           */
/*        Department Class           */
/*           */
/*=======================================*/
class Department
{
private :
    Employee* empList[100];
    int index;

public :
    Department() : index(0) {};
    void AddEmployee(Employee* emp);
    void ShowList() const;
};

void Department::AddEmployee(Employee *emp)
{
    empList[index++] = emp;
}

void Department::ShowList() const
{
    for(int i = 0; i < index; i++)
    {
        cout<<"name   : "<<empList[i]->GetName()<<endl;
        //cout<<"salary : "<<empList[i]->GetPay()<<endl;
        cout<<endl;
    }
}

/*=======================================*/
/*           */
/*         Main Function             */
/*           */
/*=======================================*/
int main(void)
{
    Department dept;

    //직원등록
    dept.AddEmployee(new Permanent("KIM", 1000));
    dept.AddEmployee(new Permanent("PARK", 1500));

    dept.AddEmployee(new Temporary("HAN", 10, 200));
    dept.AddEmployee(new Temporary("JANG", 12, 300));

    dept.ShowList();

    return 0;
}

반응형

'C, C++, Java' 카테고리의 다른 글

P304.cpp  (0) 2014.05.02
CPointer2.cpp  (0) 2014.05.02
Person.cpp  (0) 2014.04.30
P256.cpp  (0) 2014.04.30
Student.cpp  (0) 2014.04.30

#include <iostream>
#include <string.h>

using std::cout;
using std::endl;

class Person
{
 char name[20];
 int  age;

public :
 int GetAge() const
 {
  return age;
 }

 const char* GetName() const
 {
  return name;
 }

 Person(const char* _name, int _age)
 {
  age = _age;
  strcpy(name, _name);
 }

 void ShowData() const
 {
  cout<<"Name : "<<name<<endl;
  cout<<"Age  : "<<age<<endl;
 }
};

int main(void)
{
 Person KJ("KJPark", 37);
 KJ.ShowData();

 return 0;
}

반응형

'C, C++, Java' 카테고리의 다른 글

CPointer2.cpp  (0) 2014.05.02
EmployeeManager3.cpp  (0) 2014.05.02
P256.cpp  (0) 2014.04.30
Student.cpp  (0) 2014.04.30
C++ 초보자를 위한 좋은 사이트  (0) 2013.06.25

/*
 P256.cpp
*/

#include <iostream>

using std::endl;
using std::cout;

class AAA
{
public :
 AAA()
 {
  cout<<"AAA() call!"<<endl;
 }
 ~AAA()
 {
  cout<<"~AAA() call!"<<endl;
 }
};

class BBB : public AAA
{
public :
 BBB()
 {
  cout<<"BBB() call!"<<endl;
 }
 ~BBB()
 {
  cout<<"~BBB() call!"<<endl;
 }
};

int main(void)
{
 BBB bbb;
 return 0;
}

 

반응형

'C, C++, Java' 카테고리의 다른 글

EmployeeManager3.cpp  (0) 2014.05.02
Person.cpp  (0) 2014.04.30
Student.cpp  (0) 2014.04.30
C++ 초보자를 위한 좋은 사이트  (0) 2013.06.25
출퇴근 하면서 짬짬이 취미로 볼려고 열혈강의 C책을 다시 펴봤다.  (0) 2013.01.13

#include <iostream>
#include <string.h>

using std::cout;
using std::endl;

class Person
{
 char name[20];
 int  age;

public :
 int GetAge() const
 {
  return age;
 }

 const char* GetName() const
 {
  return name;
 }

 Person(const char* _name, int _age)
 {
  age = _age;
  strcpy(name, _name);
 }

};

class Student:public Person
{
 char major[20];

public :

 Student(const char* _name, int _age, const char* _major) : Person(_name, _age)
 {
  strcpy(major, _major);
 }

 const char* GetMajor() const
 {
  return major;
 }


 void ShowData() const
 {
  cout<<"Name  : "<<GetName()<<endl;
  cout<<"Age   : "<<GetAge()<<endl;
  cout<<"Major : "<<GetMajor()<<endl;
 }
};


int main(void)
{
 Student KJ("KJPark", 37, "BA");
 KJ.ShowData();

 Student YH("YH.Ahn", 39, "GI");
 YH.ShowData();
 return 0;
}

반응형

'C, C++, Java' 카테고리의 다른 글

Person.cpp  (0) 2014.04.30
P256.cpp  (0) 2014.04.30
C++ 초보자를 위한 좋은 사이트  (0) 2013.06.25
출퇴근 하면서 짬짬이 취미로 볼려고 열혈강의 C책을 다시 펴봤다.  (0) 2013.01.13
웹에서 Compile  (0) 2013.01.09

 예전에는 곧죽어도 초보는 아니고 어느 정도는 한다고 생각을 했는데, 나이를 먹어가면서 점점 자신에 대해서 냉혹해지더라. 왜냐하면 지금 나이는 전문적인 프로그래머들조차 이제는 관리나 다른 업무로 전향을 고려할만한 나이가 되었기 때문이다. 얼마전에 35번째 생일을 지났고 사실 학교를 1년 정도 일찍 들어갔기 때문에 친구들 중에 이쪽 일을 하게 된다면 지금쯤 프로젝트 매니저를 하고 있을테니.


 오늘 이글루스 블로그를 둘러보다가 우연히 간단한 Up/Down 프로그램을 C로 작성한 것을 봤다. 코딩 그 자체보다는 말이지 그 안에 들어가는 로직이 더 중요한 것이라고 본다. 문제는 내가 거기 나오는 것을 제대로 만들 정도의 프로그래밍 실력도 로직을 짤만한 능력도 안된다는 것을 말이다. 차라리 통계 문제를 푼다면 몰라도 이런 제길 이런 것을 푸는 것은 결코 쉬운 일이 아니더란 말이지.


 아, 그래서 다시 Visual Studio를 켜고 해보려고 했는데, 하나도 기억이 나지를 않더만. 그래서 구해 놓은 게 아래 사이트 주소란 말이지.


http://blog.naver.com/PostView.nhn?blogId=xtelite&logNo=50133489483


 R이야 R Studio를 열면 되고, 더군다나 정말 믿고 의지할만한 레퍼런스 책이 있으니까 더이상은 걱정되지 않는다. 예전에는 몰랐는데 이 정도 괜찮은 책을 갖고 있는게 사람에게 얼마나 의지할만한지, 얼마나 사람을 안정적으로 만드는지 모를 것이다. 더군다나 R은 한국에서 처음부터 끝까지 제대로 된 번역이 별로 존재하지 않으며, 실제 통계전공자들도 전체 기능을 모두 쓰지는 않는다. 그리고 통계전공자들이 쓰는 기능들은 상당히 제한적이고 데이터를 다루는데 그리 많은 공을 들이지 않는다. 자료가 작고 다른 엑셀이나 그런 것들로 조물락 거릴 수 있다면 모르겠지만, 실제 대용량 데이터를 능수능란하게 다루려면 일단 그 분야의 지식을 쌓아야 한다.


 나도 제대로 sas를 파기 전에는 sas가 주는 막강한 데이터 핸들링과 프로그래밍 기능에 대해서 별다른 의미를 느끼지 못했다. 그러나 점점 더 많은 것들을 배우면서 실제 통계 팩키징의 강력한 통계 기능과 더불어 데이터 핸들링도 필요하다는 생각을 하게 되었다. 좀더 많은 것들을 배우게 된다면 많은 도움이 되겠지만 C는 내게 너무나도 어렵고 복잡한 것이라는 생각을 많이 하게 된다. 예전처럼 무턱대고 코딩을 한다고 해서 실력이 늘지도 않는다는 것을 알게 되었다.


 그래서 devpia에서 강의를 하나 들어보려고 생각중이다. 가장 큰 이유는 내가 프로그래밍과 알고리즘에는 정말 정말 잼병이라는 것을 알게 된 것이다. 더군다나 말이지 나중에는 이해하고 기억하는 것보다는 대충 이해하고 사용하고 기억 저편으로 묻어 두는게 내 특징이라는 것이다. sas를 배울 때 그렇게 배워서 그런지 정말 잘하는 것이 아니면 정말 대충 알아보고 나중에는 까먹는다.


 여하튼 출퇴근 하면서 R 책을 봐야겠다. 아니면 답이 없다. 회사에서는 짬짬이 VBA책과 통계책을 좀 봐둬야 할테고. 이제 대학원이 끝났으니 내 마음대로 해보고 싶은 것들은 해봐야지.




 언제 봐도 활짝 웃어주는 우리 한승연님은, 날 기분 좋게 해주신다. 울 아내도 이렇게 밝게 웃어줄 수 있다면 정말 좋을텐데 말이지. 아내는 네 아이들과 남편을 돌보느라 늘 정신이 없으시다.


반응형

'C, C++, Java' 카테고리의 다른 글

P256.cpp  (0) 2014.04.30
Student.cpp  (0) 2014.04.30
출퇴근 하면서 짬짬이 취미로 볼려고 열혈강의 C책을 다시 펴봤다.  (0) 2013.01.13
웹에서 Compile  (0) 2013.01.09
kj_001.cpp  (0) 2013.01.02

+ Recent posts