#include <iostream>
#include <string>
#include <memory>
#include <vector>
using namespace std;
// Part B
struct Room
{
int d_noSeat;
bool d_hasProjector;
Room( ) = default ;
Room( const Room& r) :
d_noSeat( r.d_noSeat ) ,
d_hasProjector( r.d_hasProjector )
{ }
} ;
class Event
{
std:: shared_ptr < Room> d_room;
std:: string d_name;
public :
Event( ) :
d_room( 0 ) ,
d_name( "" )
{ }
Event( Room& r, const std:: string & name) :
d_room( new Room( r) ) ,
d_name( name)
{ }
Event( const Event& e) :
d_room( new Room( * e.d_room ) ) ,
d_name( e.d_name )
{ }
void print( )
{
std:: cout << "Event: " << d_name;
if ( d_room ! = 0 )
{
std:: cout << " in size " << d_room- > d_noSeat;
if ( d_room- > d_hasProjector)
std:: cout << " with" ;
else
std:: cout << " without" ;
std:: cout << " projector" ;
}
std:: cout << std:: endl ;
return ;
}
~Event( ) { }
} ;
int main( )
{
const int noLect = 5 ;
Room r;
std:: vector < Event> lectures;
for ( int i = 0 ; i < noLect; ++ i)
{
r.d_noSeat = i + 1 ;
r.d_hasProjector = ! r.d_hasProjector ;
lectures.emplace_back ( r, "CSI2372" ) ;
lectures[ i] .print ( ) ;
}
std:: cout << "-------------------" << std:: endl ;
for ( int i = 0 ; i < noLect; ++ i)
{
lectures[ i] .print ( ) ;
}
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RyaW5nPgojaW5jbHVkZSA8bWVtb3J5PgojaW5jbHVkZSA8dmVjdG9yPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCi8vIFBhcnQgQgpzdHJ1Y3QgUm9vbSAKewoJaW50IGRfbm9TZWF0OwoJYm9vbCBkX2hhc1Byb2plY3RvcjsKCglSb29tKCkgPSBkZWZhdWx0OwoKCVJvb20oY29uc3QgUm9vbSYgcikgOgoJCWRfbm9TZWF0KHIuZF9ub1NlYXQpLAoJCWRfaGFzUHJvamVjdG9yKHIuZF9oYXNQcm9qZWN0b3IpCgl7fQp9OwoKCmNsYXNzIEV2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