help with a not declared code error

im writing a program to display a tweet. it has a subject and message. i get a code error:
ec3.cpp: In member function ‘Tweet Twitter::gettweet(std::string)’:
ec3.cpp:60:15: error: ‘tweet’ was not declared in this scope
return tweet();
im not sure what i need to do to fix this error

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
  #include <iostream>
#include <string>
#include <vector>

using namespace std;

class Tweet
{public:
 Tweet(string s, string m);
 string getSubject();
 string getMessage();
 void changeMessage(string m);
private:
 string subject;
 string message;
};

Tweet::Tweet(string s, string m)
{subject = s;
 message = m;
}

string Tweet::getSubject()
{return subject;
}

string Tweet::getMessage()
{return message;
}

void Tweet::changeMessage(string m)
{message = m;
}

class Twitter
{public:
 Twitter();
 void addTweet(Tweet newmessage);
 Tweet gettweet(string subject);
private:
 vector<Tweet> messages;
};

Twitter::Twitter()
{
}

void Twitter::addTweet(Tweet newmessage)
{messages.push_back(newmessage);
}

Tweet Twitter::gettweet(string subject)
{for(int i=0; i<messages.size();i++)
 {if(messages[i].getSubject() == subject)
  {return messages[i];
  }
 return tweet();
 }

}

int main()
{Twitter t = Twitter();
 Tweet s = Tweet("FINISHED MIDTERM","ACED IT");
 t.addTweet(s);
}
Several things,
At line 57, tweet() is spelled with a lowercase 't'.
If it's changed to uppercase Tweet() that might help, but then you also need to supply the parameters (as in line 64).
Also, line 57 seems to be misplaced, it should be moved outside the for loop.

Topic archived. No new replies allowed.