two_frn.cpp

本文提供了一个使用 C++ 编写的类定义示例,该类用于表示地理位置,并展示了如何实现构造函数、成员函数以及运算符重载。具体包括了拷贝赋值运算符、加法运算符的重载实现。

  name="google_ads_frame" marginwidth="0" marginheight="0" src="http://pagead2.googlesyndication.com/pagead/ads?client=ca-pub-5572165936844014&dt=1194442938015&lmt=1194190197&format=336x280_as&output=html&correlator=1194442937843&url=file%3A%2F%2F%2FC%3A%2FDocuments%2520and%2520Settings%2Flhh1%2F%E6%A1%8C%E9%9D%A2%2FCLanguage.htm&color_bg=FFFFFF&color_text=000000&color_link=000000&color_url=FFFFFF&color_border=FFFFFF&ad_type=text&ga_vid=583001034.1194442938&ga_sid=1194442938&ga_hid=1942779085&flash=9&u_h=768&u_w=1024&u_ah=740&u_aw=1024&u_cd=32&u_tz=480&u_java=true" frameborder="0" width="336" scrolling="no" height="280" allowtransparency="allowtransparency"> #include <iostream.h>

class loc
{
  int longitude, latitude;
  public:
    loc(void) {}                //  Used to construct temporaries
    loc (int lg, int lt)
      {
      longitude = lg;
      latitude = lt;
      }

    void show(void)
      {
      cout << longitude << " ";
      cout << latitude << endl;
      }

    loc operator=(loc op2);
    friend loc operator+(loc op1, int op2);   //  Friend overloaded
    friend loc operator+(int op1, loc op2);   //  Friend overloaded
  };

loc loc::operator=(loc op2)
  {
  longitude = op2.longitude;
  latitude = op2.latitude;

  return *this;
  }

loc operator+(loc op1, int op2)
  {
  loc temp;

  temp.longitude = op1.longitude + op2;
  temp.latitude = op1.latitude + op2;

  return temp;
  }

loc operator+(int op1, loc op2)
  {
  loc temp;

  temp.longitude = op1 + op2.longitude;
  temp.latitude = op1 + op2.latitude;

  return temp;
  }


void main(void)
  {
  loc ob1(10,20), ob2( 5,30), ob3( 7,14);

  ob1.show();
  ob2.show();
  ob3.show();
  ob1 = ob2 + 10;
  ob3 = 10 + ob3;
  ob1.show();
  ob3.show();
  }

########################## TCL Event Handlers ############################ fanuc_system_A.tcl - lathe## This is a 2-Axis Horizontal Lathe Machine.## Created by Postino @ Fri Mar 9 12:19:40 2018 -0800# with Post Builder version 12.0.2.##########################################################################=============================================================proc PB_CMD___log_revisions { } {#=============================================================# Dummy command to log changes in this post --## 15-Jul-2014 gsl - Initial version# 28-Oct-2015 shuai - Add PB_CMD_uplevel_MOM_generic_cycle to check non-cutting motions.# Output contour data or tracking data based on if UDE (Cutter Compensation)# has been set. Make the return motion output after lathe rough cycle G71/G71.# 05-Nov-2015 shuai - Output finish operation G70 using previous rough contour data# if the subroutine name is same between them.# 25-Dec-2015 shuai - Add command PB_CMD_check_additional_profiling, PB_CMD_check_first_buffer_for_return_motion,# PB_CMD_finish_turn_cycle_contour_start, PB_CMD_finish_turn_cycle_contour_end,# PB_CMD_output_turning_cycle_command, PB_CMD_override_rough_contour_data_with_finish,# PB_CMD_set_contour_motion, PB_CMD_calculate_contour_line_number,# PB_CMD_set_turning_cycle_type and PB_CMD_calculate_parameters_for_turning_cycle_block.# 17-May-2016 Jintao - Add mom_kin_lathe_cycle_workplane_transform to fix PR6763943# 25-Nov-2016 shuai - Improve the functionality of Lathe Rough Cycle (G70/ G71/G72). The following issues have been enhanced.# - 1. In MOM_generic_cycle event:# - 1.1 Remove the checking condition for G70\G71\G72 that whether a from point has been set or not.# - 1.2 If a finish operation uses the previous corresponding contour of a rough turning operation, it will also need to skip to the next generic event.# - 2. Lathe rough cycle has been initialized in MOM_generic_cycle, so remove the command "PB_CMD_init_rough_turn_cycle_output" from proc "PB_approach_move".# - 3. In PB_CMD_init_rough_turn_cycle_output, additional profiling should be checked to fulfill some conditions when initializing contour data.# - 4. Add a new proc "PB_CMD_check_settings_for_additional_profiling" to check the settings for additional profile.# - 5. Add a new proc "PB_CMD_check_variables_for_turning_rough_cycle" to check some variables for turning rough cycle.# - 6. Adjust the line number according to turning operation type in PB_CMD_calculate_contour_line_number so as to get the correct values for parameters P and Q.# - 7. Exclude the own name of rough turning operation from the operation name list in command PB_CMD_turn_cycle_contour_end# when contour data of rough operation is overridden by finish operation.# 13-Dec-2016 shuai - Bug fix PR7290132. Output the correct line number for P and Q no matter the output status of sequence number is ON or OFF.# Delete the original command "PB_CMD_output_spindle". Rename the command "PB_CMD_output_spindle_speed" to "PB_CMD_output_spindle".# Update the command "PB_CMD_calculate_contour_line_number".# 21-Dec-2016 shuai - Bug fix PR7290203.# Refactor the output logic for lathe rough cycle function# to make the events content between the second MOM_generic_cycle (EXCLUDE) and MOM_contour_end (INCLUDE)# output at the end position of MOM_contour_end event.# 1. Update the handlers.# "MOM_linear_move", "MOM_circular_move", "MOM_contour_start" and "MOM_generic_cycle".# 2. Update the commands.# "PB_CMD_calculate_parameters_for_turning_cycle_block", "PB_CMD_finish_turn_cycle_contour_start", "PB_CMD_finish_turn_cycle_contour_end",# "PB_CMD_init_rough_turn_cycle_output", "PB_CMD_output_turning_cycle_command", "PB_CMD_override_rough_contour_data_with_finish",# "PB_CMD_turn_cycle_contour_start", "PB_CMD_turn_cycle_contour_end" and "PB_CMD_uplevel_MOM_generic_cycle".# 3. Delete the commands.# "PB_CMD__check_block_linear_for_rough_turn_cycle", "PB_CMD__check_block_circular_move_for_rough_turn_cycle", "PB_CMD__check_block_skip_for_rough_turn_cycle",# "PB_CMD__check_block_rapid_move_for_return_motion", "PB_CMD_check_first_buffer_for_return_motion" and "PB_CMD_calculate_contour_line_number".# 5. Delete the blocks.# "circular_move_rough_turn_cycle" and "linear_move_rough_turn_cycle".# 6. Enhance the MOM_abort command with "catch" to make it not output error message.# 7. Enhance the temp file name with clock time to make it unique in current output folder.# 25-April-2017 lili - Update implementation of lathe rough cycle function. All related commands please see PB_CMD_init_turn_cycle_setting, PB_CMD_uplevel_MOM_generic_cycle,# PB_CMD_turn_cycle_contour_start and PB_CMD_turn_cycle_contour_end.# Add PB_CMD_init_turn_cycle_setting at "start of program".} set cam_post_dir [MOM_ask_env_var UGII_CAM_POST_DIR] set mom_sys_this_post_dir "[file dirname [info script]]" set mom_sys_this_post_name "[file rootname [file tail [info script]]]" if { ![info exists mom_sys_post_initialized] } { if { ![info exists mom_sys_ugpost_base_initialized] } { source ${cam_post_dir}ugpost_base.tcl set mom_sys_ugpost_base_initialized 1 } set mom_sys_debug_mode OFF if { ![info exists env(PB_SUPPRESS_UGPOST_DEBUG)] } { set env(PB_SUPPRESS_UGPOST_DEBUG) 0 } if { $env(PB_SUPPRESS_UGPOST_DEBUG) } { set mom_sys_debug_mode OFF } if { ![string compare $mom_sys_debug_mode "OFF"] } { proc MOM_before_each_add_var {} {} proc MOM_before_each_event {} {} proc MOM_before_load_address {} {} proc MOM_end_debug {} {} } else { set cam_debug_dir [MOM_ask_env_var UGII_CAM_DEBUG_DIR] source ${cam_debug_dir}mom_review.tcl } #### Listing File variables set mom_sys_list_output "OFF" set mom_sys_header_output "OFF" set mom_sys_list_file_rows "40" set mom_sys_list_file_columns "30" set mom_sys_warning_output "OFF" set mom_sys_warning_output_option "FILE" set mom_sys_group_output "OFF" set mom_sys_list_file_suffix "lpt" set mom_sys_output_file_suffix "ptp" set mom_sys_commentary_output "ON" set mom_sys_commentary_list "x z feed speed" set mom_sys_pb_link_var_mode "OFF" if { [string match "OFF" $mom_sys_warning_output] } { catch { rename MOM__util_print ugpost_MOM__util_print } proc MOM__util_print { args } {} } MOM_set_debug_mode $mom_sys_debug_mode if { [string match "OFF" $mom_sys_warning_output] } { catch { rename MOM__util_print "" } catch { rename ugpost_MOM__util_print MOM__util_print } } #============================================================= proc MOM_before_output { } { #============================================================= # This command is executed just before every NC block is # to be output to a file. # # - Never overload this command! # - Any customization should be done in PB_CMD_before_output! # if { [llength [info commands PB_CMD_kin_before_output]] &&\ [llength [info commands PB_CMD_before_output]] } { PB_CMD_kin_before_output } # Write output buffer to the listing file with warnings global mom_sys_list_output if { [string match "ON" $mom_sys_list_output] } { LIST_FILE } else { global tape_bytes mom_o_buffer if { ![info exists tape_bytes] } { set tape_bytes [string length $mom_o_buffer] } else { incr tape_bytes [string length $mom_o_buffer] } } } if { [string match "OFF" [MOM_ask_env_var UGII_CAM_POST_LINK_VAR_MODE]] } { set mom_sys_link_var_mode "OFF" } else { set mom_sys_link_var_mode "$mom_sys_pb_link_var_mode" } set mom_sys_control_out "(" set mom_sys_control_in ")" set mom_sys_post_initialized 1 } set mom_sys_use_default_unit_fragment "ON" set mom_sys_alt_unit_post_name "fanuc_system_A__MM.pui"########## SYSTEM VARIABLE DECLARATIONS ############## set mom_sys_rapid_code "0" set mom_sys_linear_code "1" set mom_sys_circle_code(CLW) "2" set mom_sys_circle_code(CCLW) "3" set mom_sys_lathe_thread_advance_type(1) "33" set mom_sys_lathe_thread_advance_type(2) "34" set mom_sys_lathe_thread_advance_type(3) "35" set mom_sys_delay_code(SECONDS) "4" set mom_sys_delay_code(REVOLUTIONS) "4" set mom_sys_cutcom_code(OFF) "40" set mom_sys_cutcom_code(LEFT) "41" set mom_sys_cutcom_code(RIGHT) "42" set mom_sys_adjust_code "43" set mom_sys_adjust_code_minus "44" set mom_sys_adjust_cancel_code "49" set mom_sys_unit_code(IN) "20" set mom_sys_unit_code(MM) "21" set mom_sys_cycle_drill_break_chip_code "73" set mom_sys_cycle_off "80" set mom_sys_cycle_drill_code "81" set mom_sys_cycle_drill_deep_code "83" set mom_sys_cycle_drill_dwell_code "82" set mom_sys_cycle_tap_code "84" set mom_sys_cycle_bore_code "85" set mom_sys_output_code(ABSOLUTE) "90" set mom_sys_output_code(INCREMENTAL) "91" set mom_sys_reset_code "50" set mom_sys_feed_rate_mode_code(IPM) "98" set mom_sys_feed_rate_mode_code(IPR) "99" set mom_sys_feed_rate_mode_code(FRN) "93" set mom_sys_spindle_mode_code(SFM) "96" set mom_sys_spindle_mode_code(RPM) "97" set mom_sys_return_code "28" set mom_sys_cycle_ret_code(AUTO) "98" set mom_sys_cycle_ret_code(MANUAL) "99" set mom_sys_program_stop_code "0" set mom_sys_optional_stop_code "1" set mom_sys_end_of_program_code "2" set mom_sys_spindle_direction_code(CLW) "3" set mom_sys_spindle_direction_code(CCLW) "4" set mom_sys_spindle_direction_code(OFF) "5" set mom_sys_tool_change_code "6" set mom_sys_coolant_code(MIST) "7" set mom_sys_coolant_code(ON) "8" set mom_sys_coolant_code(FLOOD) "8" set mom_sys_coolant_code(OFF) "9" set mom_sys_head_code(INDEPENDENT) "21" set mom_sys_head_code(DEPENDENT) "22" set mom_sys_rewind_code "30" set mom_sys_sim_cycle_drill "0" set mom_sys_sim_cycle_drill_dwell "0" set mom_sys_sim_cycle_drill_deep "0" set mom_sys_sim_cycle_drill_break_chip "0" set mom_sys_sim_cycle_tap "0" set mom_sys_sim_cycle_bore "0" set mom_sys_cir_vector "Vector - Arc Start to Center" set mom_sys_spindle_max_rpm_code "50" set mom_sys_spindle_cancel_sfm_code "93" set mom_sys_spindle_ranges "0" set mom_sys_rewind_stop_code "\#" set mom_sys_home_pos(0) "0" set mom_sys_home_pos(1) "0" set mom_sys_home_pos(2) "0" set mom_sys_zero "0" set mom_sys_opskip_block_leader "/" set mom_sys_seqnum_start "10" set mom_sys_seqnum_incr "10" set mom_sys_seqnum_freq "1" set mom_sys_seqnum_max "9999" set mom_sys_lathe_x_double "1" set mom_sys_lathe_i_double "1" set mom_sys_lathe_x_factor "1" set mom_sys_lathe_z_factor "1" set mom_sys_lathe_i_factor "1" set mom_sys_lathe_k_factor "1" set mom_sys_leader(N) "N" set mom_sys_leader(X) "X" set mom_sys_leader(Y) "Y" set mom_sys_leader(Z) "Z" set mom_sys_turret_index(INDEPENDENT) "1" set mom_sys_turret_index(DEPENDENT) "2" set mom_sys_delay_param(SECONDS,format) "Dwell_SECONDS" set mom_sys_delay_param(REVOLUTIONS,format) "Dwell_REVOLUTIONS" set mom_sys_contour_feed_mode(LINEAR) "IPM" set mom_sys_rapid_feed_mode(LINEAR) "IPM" set mom_sys_cycle_feed_mode "IPM" set mom_sys_feed_param(IPM,format) "Feed_IPM" set mom_sys_feed_param(IPR,format) "Feed_IPR" set mom_sys_feed_param(FRN,format) "Feed_INV" set mom_sys_vnc_rapid_dogleg "1" set mom_sys_prev_mach_head "" set mom_sys_curr_mach_head "" set mom_sys_output_cycle95 "1" set mom_sys_lathe_y_factor "1" set mom_sys_head_code(INDEPENDENT) "21" set mom_sys_head_code(DEPENDENT) "22" set mom_sys_advanced_turbo_output "0" set mom_sys_linearization_method "angle" set mom_sys_tool_number_max "32" set mom_sys_tool_number_min "1" set mom_sys_post_description "This is a 2-Axis Horizontal Lathe Machine." set mom_sys_word_separator " " set mom_sys_end_of_block "" set mom_sys_ugpadvkins_used "0" set mom_sys_post_builder_version "12.0.2"####### KINEMATIC VARIABLE DECLARATIONS ############## set mom_kin_4th_axis_center_offset(0) "0.0" set mom_kin_4th_axis_center_offset(1) "0.0" set mom_kin_4th_axis_center_offset(2) "0.0" set mom_kin_4th_axis_max_limit "0.0" set mom_kin_4th_axis_min_incr "0.0" set mom_kin_4th_axis_min_limit "0.0" set mom_kin_4th_axis_point(0) "0.0" set mom_kin_4th_axis_point(1) "0.0" set mom_kin_4th_axis_point(2) "0.0" set mom_kin_4th_axis_zero "0.0" set mom_kin_5th_axis_center_offset(0) "0.0" set mom_kin_5th_axis_center_offset(1) "0.0" set mom_kin_5th_axis_center_offset(2) "0.0" set mom_kin_5th_axis_max_limit "0.0" set mom_kin_5th_axis_min_incr "0.0" set mom_kin_5th_axis_min_limit "0.0" set mom_kin_5th_axis_point(0) "0.0" set mom_kin_5th_axis_point(1) "0.0" set mom_kin_5th_axis_point(2) "0.0" set mom_kin_5th_axis_zero "0.0" set mom_kin_arc_output_mode "FULL_CIRCLE" set mom_kin_arc_valid_plane "XY" set mom_kin_clamp_time "2.0" set mom_kin_dependent_head "NONE" set mom_kin_flush_time "2.0" set mom_kin_ind_to_dependent_head_x "0" set mom_kin_ind_to_dependent_head_z "0" set mom_kin_independent_head "NONE" set mom_kin_linearization_flag "1" set mom_kin_linearization_tol "0.001" set mom_kin_machine_resolution ".0001" set mom_kin_machine_type "lathe" set mom_kin_machine_zero_offset(0) "0.0" set mom_kin_machine_zero_offset(1) "0.0" set mom_kin_machine_zero_offset(2) "0.0" set mom_kin_max_arc_radius "9999.9999" set mom_kin_max_dpm "0.0" set mom_kin_max_fpm "400" set mom_kin_max_fpr "1000" set mom_kin_max_frn "99999.999" set mom_kin_min_arc_length "0.01" set mom_kin_min_arc_radius "0.0001" set mom_kin_min_dpm "0.0" set mom_kin_min_fpm "0.1" set mom_kin_min_fpr "0.001" set mom_kin_min_frn "0.001" set mom_kin_output_unit "IN" set mom_kin_pivot_gauge_offset "0.0" set mom_kin_post_data_unit "IN" set mom_kin_rapid_feed_rate "600" set mom_kin_tool_change_time "0.0" set mom_kin_x_axis_limit "40" set mom_kin_y_axis_limit "40" set mom_kin_z_axis_limit "35"if [llength [info commands MOM_SYS_do_template] ] { if [llength [info commands MOM_do_template] ] { rename MOM_do_template "" } rename MOM_SYS_do_template MOM_do_template}#=============================================================proc MOM_start_of_program { } {#============================================================= global mom_logname mom_date is_from global mom_coolant_status mom_cutcom_status global mom_clamp_status mom_cycle_status global mom_spindle_status mom_cutcom_plane pb_start_of_program_flag global mom_cutcom_adjust_register mom_tool_adjust_register global mom_tool_length_adjust_register mom_length_comp_register global mom_flush_register mom_wire_cutcom_adjust_register global mom_wire_cutcom_status set pb_start_of_program_flag 0 set mom_coolant_status UNDEFINED set mom_cutcom_status UNDEFINED set mom_clamp_status UNDEFINED set mom_cycle_status UNDEFINED set mom_spindle_status UNDEFINED set mom_cutcom_plane UNDEFINED set mom_wire_cutcom_status UNDEFINED catch {unset mom_cutcom_adjust_register} catch {unset mom_tool_adjust_register} catch {unset mom_tool_length_adjust_register} catch {unset mom_length_comp_register} catch {unset mom_flush_register} catch {unset mom_wire_cutcom_adjust_register} set is_from "" catch { OPEN_files } ;# Open warning and listing files LIST_FILE_HEADER ;# List header in commentary listing global mom_sys_post_initialized if { $mom_sys_post_initialized > 1 } { return } set ::mom_sys_start_program_clock_seconds [clock seconds] # Load parameters for alternate output units PB_load_alternate_unit_settings rename PB_load_alternate_unit_settings ""#************uplevel #0 {#=============================================================proc MOM_sync { } {#============================================================= if [llength [info commands PB_CMD_kin_handle_sync_event] ] { PB_CMD_kin_handle_sync_event }}#=============================================================proc MOM_set_csys { } {#============================================================= if [llength [info commands PB_CMD_kin_set_csys] ] { PB_CMD_kin_set_csys }}#=============================================================proc MOM_msys { } {#=============================================================}#=============================================================proc MOM_end_of_program { } {#===================
最新发布
09-07
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值