я вам возможно сейчас жизнь сломаю, но вот вам
#include <string>
#include <utility>
#include <iostream>
class CredentialsInfo {
std::string _login, _password;
public:
CredentialsInfo() {}
CredentialsInfo(const std::string& login, const std::string& password)
: _login(login)
, _password(password)
{ }
public:
std::string Login() const {
return _login;
}
std::string Password() const {
return _password;
}
void SetLogin(const std::string& newLogin) {
_login = newLogin;
}
void SetPassword(const std::string& newPassword) {
_password = newPassword;
}
friend std::ostream& operator<<(std::ostream&, const CredentialsInfo&);
};
std::ostream& operator<<(std::ostream& out, const CredentialsInfo& info) {
return out << info._login << "; " << info._password;
}
template <class DataClass>
class Queue {
public:
typedef DataClass value_type;
private:
struct QueueNode {
value_type Value;
QueueNode* Next;
QueueNode(value_type&& value)
: Value(std::move(value))
, Next(nullptr)
{ }
};
QueueNode *_head, *_tail;
public:
Queue()
: _head(nullptr)
, _tail(nullptr)
{ }
~Queue() {
while(_head) {
auto tmp = _head;
_head = _head->Next;
delete tmp;
}
}
public:
template <class Data>
void Add(Data&& data) {
auto* newNode = new QueueNode(std::forward<Data>(data));
if (_head) {
_tail->Next = newNode;
_tail = newNode;
} else {
_head = _tail = newNode;
}
}
template<class... Args>
void Add(Args&&... args) {
Add(value_type(std::forward<Args>(args)...));
}
void Show(std::ostream& out) const {
auto it = _head;
while (it) {
out << it->Value << '\n';
it = it->Next;
}
out.flush();
}
};
typedef Queue<CredentialsInfo> CredentialsQueue;
int main(int, char**) {
CredentialsQueue queue;
queue.Add("s", "ss");
queue.Add("1", "op");
queue.Add("1", "p");
queue.Show(std::cout);
return 0;
}