forked from stevenarditti/part2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
string.h
50 lines (40 loc) · 1.22 KB
/
string.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#pragma once
#include <iostream>
#include "object.h"
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
// A String is an Object
class String: public Object {
public:
const char* value_;
int size_;
size_t hash_code;
// Constructor
// hash code will be initialized to 0
// the given char* will be contrcted into String
String(const char* value) : Object() {
value_ = value;
size_ = strlen(value);
hash_code = 0;
hash();
}
~String() {
delete [] value_;
}
//Return the size of the String
virtual size_t get_size();
// Check if this String is equal to given String.
// Gievn String is an object
virtual bool equals(Object *object);
//Concatinate given String to this String.
// This String will be in the front
String* concat(String *o);
// Return field hash_code if hash code is not zero.
// Otherwise go to hash_me function.
virtual size_t hash();
// Make hash code a valid hash code
virtual void hash_me();
// Return char pointer value_
virtual const char* getValue();
};