Can someone help me spot my errors?

Hello everyone, so I have the following code for a school project. I have included the code and errors, would someone mind helping me on where i went wrong here?

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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/*
Midterm Practice
Feb 21, 2013*/

#include<iostream>
#include<vector>
#include<string>

using namespace std;


class Email
{
	public:
		Email();
		Email(string se, string re, string su, string te);
		string get_sender();
		string get_recipient();
		string get_subject();
		string get_text();
		void addtext(string newtext);
	private:
		string sender;
		string recipient;
		string subject;
		string text;
};

Email::Email(string se, string re, string su, string te)
{
	sender = se;
	recipient = re;
	subject = su;
	text = te;
}

string Email::get_sender()
{
	return sender;
}

string Email::get_recipient()
{
	return recipient;
}

string Email::get_subject()
{
	return subject;
}

string Email::get_text()
{
	return text;
}

void Email::addtext(string newtext)
{
	text +=newtext;
}

class Mailbox
{
	public:
		Mailbox();
		void addmessage(Email newmessage);
		Email getmessage(int i);
	private:
		vector<Email> messages;
};

void Mailbox::addmessage(Email newmessage)
{
	messages.push_back(newmessage);
}

vector<string> Email.getmessage(int i)
{
	return messages[i];
}

int main()
{
	string sender;
	string subject;
	string recipient;
	string text;
	cout<<"Enter sender's name";
	cin>> sender);
	cout<<"Enter recipient's name";
	cin>> recipient;
	cout<<"Enter subject";
	cin>> subject;
	cout<<"Type message";
	cin>> text;
	Email.new(sender, recipient, subject, text);
	Mailbox.inbox();
	inbox.addmessage(new);
}


When I attempt to compile this, I get the following errors:
1
2
3
4
5
6
7
8
9
Line:| Message:
77|error: expected initializer before '.' token|
In function 'int main()':|
96|error: expected unqualified-id before '.' token|
97|error: expected unqualified-id before '.' token|
98|error: 'inbox' was not declared in this scope|
98|error: expected type-specifier before ')' token|
||=== Build finished: 5 errors, 0 warnings ===|
closed account (3CXz8vqX)
I don't think it recognizes vector<string> perhaps you have forgotten to include something perhaps? Or missed a space maybe.
Line 77. Three problems. 1) Return type should be Email, not vector<string>.
2) Class name should be Mailbox, not Email.
3) Separator should be ::, not .
 
Email Mailbox::getmessage(int i)


Line 89: ) doesn't belong there.

Line 96. You can't use new that way. You have to declare an instance.
 
Email msg(sender, recipient, subject, text);


Line 97. Likewise. Mailbox is a class, not an instance.
 
Mailbox inbox;


Line 98: You have to pass an Email instance to addmessage.
 
inbox.addmessage (msg);  // add the instance created on line 96. 






Okay now its giving me the error
error: request for member 'addmessage' in 'inbox', which is of non-class type 'Mailbox()'|

Also, would getline(cin, sender), getline(cin, subject), etc work out better than just cin?
Please show your corrected code.
Mailbox has no method of inbox().
Topic archived. No new replies allowed.