Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In c++ class UMLPerson { // base class public: // constructors and destructor UMLPerson() : _firstName(NoName), _lastName(NoName), _address(NoAddress), _IDNumber_(0) {} UMLPerson(string firstName, string lastName, string

In c++

class UMLPerson { // base class

public:

// constructors and destructor

UMLPerson() : _firstName("NoName"), _lastName("NoName"),

_address("NoAddress"), _IDNumber_(0) {}

UMLPerson(string firstName, string lastName, string address,

unsigned _IDNumber) :

_firstName(firstName), _lastName(lastName), _address(address),

_IDNumber_(_IDNumber) {}

UMLPerson(const UMLPerson&); // copy constructor

~UMLPerson();

// Implements lexicographic comparison of UMLPerson objects based on

// last name

bool operator

{ return this->_lastName

// Implements equality based on IDNumber

bool operator== (const UMLPerson& rhs) const

{ return this->_IDNumber == rhs._IDNumber; }

bool operator== (const unsigned rhs) const

{ return this->_IDNumber == rhs; }

// accessor functions

string getFirstName() const { return _firstName; }

string getLastName() const { return _lastName; }

string getAddress() const { return _address; }

unsigned get_IDNumber() const { return _IDNumber_; }

void output(ostream& out) const { out

friend ostream& operator

friend ofstream& operator

friend ifstream& operator>> (ifstream&, UMLPerson&);

private:

string _firstName;

string _lastName;

string _address;

unsigned _IDNumber_;

};

// any of example

//Thegenericalgorithm std : : any of returns true if the predicate function

//usedfor its third parameter returns true for any item in the range

// specified by its first and second parameters; otherwise,it returns false.

#include//s t d : : cout#include//s t d : : any of#include//s t d : : array

boolisNegative (inti )

{return( i0>

}

intmain ( )

{std : : arrayfoo = {0 ,1 , 1 ,3 , 3 ,5 , 5};,7>

i f( std : : any of ( foo . begin ( ) , foo . end ( ) , isNegative ) )

std : : cout>

return 0;

}

// stable_sort example

#include//std : : cout#include//std : : stable_sort#include//std : : vector

boolcompare_as_ints (doublei ,doublej )

{return(int( i )int(>

}

intmain ( ){

doublemydoubles [ ] = { 3. 1 4 , 1. 4 1 , 2. 7 2 , 4. 6 7 , 1. 7 3 , 1. 3 2 , 1. 6 2 , 2 . 5 8 };

s t d : : vector myvector ;

myvector . assign ( mydoubles , mydoubles +8);

std : : cout

std: : stable_sort ( myvector . begin( ) , myvector . end( ) ) ;

for ( std : : vector :: iterator it=myvector . begin ( ) ; it !=myvector . end ( ) ; ++i t )

std : : cout i t ;

std : : cout

myvector . assign ( mydoubles , mydoubles +8);

std : : cout

std : : stable_sort ( myvector . begin( ) , myvector . end ( ) , compare_as_ints ) ;

for ( std : : vector:: iterator it=myvector . begin( ) ; it !=myvector . end ( ) ; ++i t )

std : : cout i t ;

std : : cout

return 0 ;

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

More Books

Students also viewed these Programming questions