Yurttas/PL/OOL/Cplusplus/F/02/07/03/00/S.cpp

From ZCubes Wiki
Jump to navigation Jump to search
 1/*
 2   Copyright(C) 2000
 3   All Rights Reserved. Salih Yurttas, ZCubes, BitsOfCode Software Systems, Inc..
 4
 5   Permission to use, copy, modify, and distribute this
 6   software and its documentation for EDUCATIONAL purposes
 7   and without fee is hereby granted provided that this
 8   copyright notice appears in all copies.
 9
10   date   : January 1, 2000.
11   author : Salih Yurttas.
12
13   S.cpp
14*/
15
16
17#include "A.h"
18
19using namespace A;
20
21#include <cstring>
22
23using namespace std;
24
25S::
26S(const char *a) {
27  if(s) {
28    s = new char[strlen(a)+1];
29    strcpy(s,a);
30  }
31  else {
32    s = new char[1];
33    *s = '\0';
34  }
35}
36
37S::
38~S() {
39  delete [] s;
40}
41
42
43char* 
44S::
45get_s() const {
46  return s;
47}