I get an error when I try to use a parametrized constructor, I am a little confused on how to use constructors. Also I have looked up constructors with google.
#include <iostream>
#include <time.h>
#include <math.h>
#include <string>
using namespace std;
class Message
{
public:
Message();
Message(string send, string recip)
{
sender=send;
recipient = recip;
}
void append(string message, string append_msg);
void to_string(string sender, string recipient);
void print(string message);
private:
string message;
string sender;
string recipient;
double time;
string append_msg;
};
void Message::append(string message, string append_msg)
{
cout << message + append_msg;
}
void Message::to_string(string sender, string recipient)
{
cout << sender+recipient << endl;
}
void Message::print(string message)
{
cout << message << endl;
}
int main()
{
Message msg;
string sender, recipient, message, append_msg;
cout << "Enter sender: ";
cin >> sender;
cout << endl;
cout << "Enter recipient: ";
cin >> recipient;
cout << endl;
cout << "Enter message: ";
cin >> message;
cout << endl;
cout << "Enter append_msg: ";
cin >> append_msg;
cout << endl;
msg.append(message, append_msg);
msg.to_string(sender, recipient);
msg.print(message);
return 0;
}