int main()
{
	Name_pairs names;
	try
	{
		names.read_names();
		names.read_ages();
		std::cout << "Names and ages unordered:\n";
		cout << names;
		names.sort();
		std::cout << "Names and ages sorted by name:\n";
		cout << names;
	}
	catch (exception &e)
	{
		cout << "error: " << e.what() << std::endl;
		keep_window_open();
		return 1;
	}
	catch (...)
	{
		cout << "Unknown exeption!\n";
		keep_window_open();
		return 2;
	}

	keep_window_open();
	return 0;
}
Exemplo n.º 2
0
void main() {
	Name_pairs n;
	read_names(n);
	read_ages(n);
	n.sort();
	
	cout << n;

	system("pause");
}
Exemplo n.º 3
0
bool operator==(const Name_pairs& aa, const Name_pairs& bb)
{
	//sort first
	Name_pairs a = aa;
	a.sort();
	Name_pairs b = bb;
	b.sort();
	//then compare, so Name_pairs is unordered;
	//check the length
	if (a.get_name().size() != b.get_name().size()){
		return false;
	}
	//check the elements each
	for (size_t i = 0; i < a.get_name().size(); ++i){
		if (a.get_name()[i] != b.get_name()[i]){
			return false;
		}
		if (a.get_ages()[i] != b.get_ages()[i]){
			return false;
		}
	}
	return true;
}
Exemplo n.º 4
0
int main()
{
    Name_pairs pairs;

    pairs.read_names();
    pairs.read_ages();

    pairs.print();

    pairs.sort();
    pairs.print();

    return 0;
}
Exemplo n.º 5
0
int main()
{
	Name_pairs name;

	name.read_names();
	name.read_ages();

	name.print();

	name.sort();

	name.print();

	// keep window open
	char cc;
	cin >> cc;
}