Strings supposed to get stored in vector, then gets printed. It's not working...

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
51
52
53
54
#include <iostream>
#include <vector>

using namespace std;

class Message {

public:
    Message ();
    Message (string, string, time_t);
    void changeSubject (string);
    void addMessage (string);
    void append();
    string getSender ();
    string getRecipient ();
    string getSubject ();
    string getMessage ();
    char* geTime ();
    void printEverything ();

private:
    string sender;
    string recipient;
    char* tstamp;
    string subject;
    vector <string> message;
};

void Message::addMessage (string messageo) {
message.push_back(messageo);
}

void Message::append () {
    int n = message.size();
    for (int x = 0; x < n; x++) {
        cout << message[x];
    }
return;
}

int main()
{
    Message person;
    string whatyouwant;
    cin >> whatyouwant;
    while (whatyouwant != "."){
        person.addMessage(whatyouwant);
        cin >> whatyouwant;
    }
   
    person.append();

    return 0;
}





The intention of my program is to take strings from the user and store them into a vector and later printing out the whole message by going through the entire vector and printing out the message one after another. The problem is, when I call the class function to print it, nothing gets printed. I'm not sure if it's even getting stored in the vector.

Please help, and thanks so much.
Last edited on
This code cannot compile because you have not defined your class constructor:
http://ideone.com/1BNqS8
Topic archived. No new replies allowed.