page191

本文通过解析一个简单的C++程序,详细阐述了传引用调用和传值调用的区别及实现方式。通过实例演示,深入理解参数传递在面向对象编程中的应用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

// page191.cpp : 定义控制台应用程序的入口点。
//C++面向对象程序设计

//练习输出结果

//传引用调用和传值调用的思路这个小题就能说明白
#include "stdafx.h"
#include <iostream>

void figure_me_out(int& x , int y , int& z);

int _tmain(int argc, _TCHAR* argv[])
{
 using namespace std ;
 int a , b ,c ;
 a = 10 ;
 b = 20 ;
 c = 30 ;
 figure_me_out(a , b , c );
 cout << a <<  " " << b << " " << c ;

 cin >> a ;
 return 0;
}


void figure_me_out(int& x , int y , int& z)
{
 using namespace std ;
 cout << x << " " << y << " " << z << endl ;
 x = 1;
 y = 2 ;
 z = 3 ;
 cout << x << " " << y << " " << z << endl ;
}

 

 

 

答案: 10 20 30

            1   2   3

             1  20  3

------------------------------------- Translated Report (Full Report Below) ------------------------------------- Process: Xcode [789] Path: /Applications/Xcode.app/Contents/MacOS/Xcode Identifier: com.apple.dt.Xcode Version: 15.2 (22503) Build Info: IDEApplication-22503000000000000~3 (15C500b) Code Type: X86-64 (Native) Parent Process: launchd [1] User ID: 501 Date/Time: 2025-03-17 04:12:45.5804 +0800 OS Version: macOS 13.7 (22H123) Report Version: 12 Anonymous UUID: D29F54A8-7282-84CD-7ABF-FA42243B8EFE Time Awake Since Boot: 130 seconds System Integrity Protection: disabled Crashed Thread: 0 Dispatch queue: com.apple.main-thread Exception Type: EXC_BAD_INSTRUCTION (SIGILL) Exception Codes: 0x0000000000000001, 0x0000000000000000 Termination Reason: Namespace SIGNAL, Code 4 Illegal instruction: 4 Terminating Process: exc handler [789] Kernel Triage: VM - (arg = 0x0) Returned success with no page VM - (arg = 0x0) Returned success with no page VM - (arg = 0x0) Returned success with no page VM - (arg = 0x0) Returned success with no page VM - (arg = 0x0) Returned success with no page Thread 0 Crashed:: Dispatch queue: com.apple.main-thread 0 CoreRE 0x1568cd2f7 re::mtl::makeDefaultDevice() + 101 1 CoreRE 0x1562d5ea3 re::RenderManager::init(re::FrameManager*, re::RenderManagerConfiguration const&, re::JobService*, re::ProfilerManager*, re::ColorManager*, re::VFXManager*, re::DepthMitigationService*, re::ImportGraphicsResources*, bool) + 191 2 CoreRE 0x1565f6ca7 re::Engine::init(re::EngineConfiguration const&) + 9249 3 CoreRE 0x156635c9f REEngineInitWithConfiguration + 13 4 RealityFoundation 0x1523b6aec __Engine.init(configuration:) + 412 5 Preview
最新发布
03-18
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值