0

Hi, I am trying to finish this small project of mine but I can't seem to solve the problem for a few days already. Its about an simple application on messaging and reading message between 2 phones but when I am doing it it doesn't seems to be too simple.:p
As I cannot seem to find out the error I'll insert the .txt file for the program instead of putting it in (code).

I would really appreciate for help on this one as I can't seem to solve this one. Thanks a lot.

Edited by mike_2000_17: Fixed formatting

Attachments
#include<iostream>
#include<string>
using namespace std;

class BasicHandphone
{
private:
 
	int f; 
	//int smsStatus[10], 
	int inboxCount;
	string sms[10];
	string smsDraft;

public:
	BasicHandphone()
	{int f = 0;}
	void draftMessage();
	void showInbox();
	void readMessage();
	string operator + (BasicHandphone &);
};

void BasicHandphone :: draftMessage()
{
cout << "Write the message below and terminate with #" << endl;
getline (cin,smsDraft,'#');
}

void BasicHandphone :: showInbox()
{
cout << "\n [INBOX] \n Inbox is empty" << endl;
}

void BasicHandphone::readMessage()
{
cout << "\n No messages" << endl;
}

string BasicHandphone :: operator >> (BasicHandphone & g)
{
g.inboxCount++;
g.f=0;
g.sms [g.inboxCount] = smsDraft;
g.f++;
g.smsStatus[g.inboxCount] = g.f;
return g.sms[g.inboxCount];
}

int main()
{
	BasicHandphone A,B;
	int choice = 0;

	while(choice != 7)
	{
		cout << "\n------MENU------" << endl;
		cout << "1 : Show Inbox handphone A" << endl;
		cout << "2 : Show Inbox handphone B" << endl;
		cout << "3 : Send SMS from A to B" << endl;
		cout << "4 : Send SMS from B to A" << endl;
		cout << "5 : Read message handphone A" << endl;
		cout << "6 : Read message handphone B" << endl;
		cout << "7 : Exit" << endl;
		cout << "------MENU------" << endl;
		while (true)
		{
			cout << "Enter choice : ";
			cin >> choice;
			if ((choice >= 1) && (choice <= 7))
				break;
		}

		switch(choice)
		{
		case 1:
			A.showInbox();
			break;
		case 2:
			B.showInbox();
			break;
		case 3:
			A.draftMessage();
			A >> B;
			break;
		case 4:
			B.draftMessage();
			B >> A;
			break;
		case 5:
			A.readMessage();
			break;
		case 6:
			B.readMessage();
			break;
		case 7: break;
		};
	}

	return 0;
}
2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by William Hemsworth
0

On line 47, you try to use the member BasicHandphone::smsStatus, which you commented out.. so by uncommenting it, you remove that error. You also fergot to add the prototype for the operator>> function, so change you class like this.

class BasicHandphone {
private:
 
   int f; 
   int smsStatus[10];
   int inboxCount;
   string sms[10];
   string smsDraft;

public:
   BasicHandphone()
   {int f = 0;}
   void draftMessage();
   void showInbox();
   void readMessage();
   [B]string operator >>(BasicHandphone & g);[/B]
   string operator + (BasicHandphone &);
};
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.