void main() { clrscr(); derived ob1(1); derived *ob2; ob2=new derived(2); { derived ob3(3); } delete(ob2); getch(); }
/************************************************ Program 3 Continued.... **************************************************/ void prog3() { loc ob1(10, 20), ob2(5, 30), ob3(90, 90); ob1.show(); ob2.show(); ++ob1; ob1.show(); // displays 11 21 ob2 = ++ob1; ob1.show(); // displays 12 22 ob2.show(); // displays 12 22 ob1 = ob2 = ob3; // multiple assignment ob1.show(); // displays 90 90 ob2.show(); // displays 90 90 }
bool Character::start_script( Bscript::EScriptProgram* prog, bool start_attached, Bscript::BObjectImp* param2, Bscript::BObjectImp* param3, Bscript::BObjectImp* param4 ) { if ( !( !start_attached || ( script_ex == NULL ) ) ) { POLLOG << "Character::start_script hiccup\n" << "Trying to start script " << prog->name.get() << "\n" << "Script " << script_ex->scriptname() << " is already running\n"; return false; // if it's going to have a passert() error, just return false. } passert( !start_attached || ( script_ex == NULL ) ); Bscript::BObject ob2( param2 ? param2 : Bscript::UninitObject::create() ); Bscript::BObject ob3( param3 ? param3 : Bscript::UninitObject::create() ); Bscript::BObject ob4( param4 ? param4 : Bscript::UninitObject::create() ); std::unique_ptr<Core::UOExecutor> ex( Core::create_script_executor() ); auto uoemod = new Module::UOExecutorModule( *ex ); ex->addModule( uoemod ); if ( prog->haveProgram ) { if ( param4 ) ex->pushArg( param4 ); if ( param3 ) ex->pushArg( param3 ); if ( param2 ) ex->pushArg( param2 ); ex->pushArg( new Module::ECharacterRefObjImp( this ) ); } ex->os_module->priority = 100; if ( ex->setProgram( prog ) ) { if ( start_attached ) { script_ex = ex.get(); uoemod->attached_chr_ = this; } uoemod->controller_.set( this ); schedule_executor( ex.release() ); return true; } else { POLLOG << "Unable to setProgram(" << prog->name.get() << ")\n"; return false; } }
Test operator - (Test& ob1, Test& ob2){ string str = str.substr(0, ob1.getName().size() - ob2.getName().size()); Test ob3(str); return ob3; }
Test operator + (Test& ob1, Test& ob2){ Test ob3(ob1.name + ob2.name); return ob3; }