为了账号安全,请及时绑定邮箱和手机立即绑定

c++关于类的练习

c++关于类的练习

C++
为啥有昵称 2017-03-02 13:53:39
#include<iostream>#include<string.h>using namespace std;class CPerson{private: char name[12]; int age; float height; long friendID; int IsMyFriend(long fid);public: void PubPrivate(long fid); void SetPrivate(char *n = " ", int a = 0, float h = 0); void SetFriendID(long fid = 12345);};int CPerson::IsMyFriend(long fid){ return fid == friendID ? 1 : 0;}void CPerson::PubPrivate(long fid){ cout << "hello" << endl; if (IsMyFriend(fid)) cout << "My friend:I am " << name << "," << age << " years old,and my height is " << height << endl; else cout << "Sorry,you are not my friend" << endl;}void CPerson::SetPrivate(char *n, int a, float h){ strcpy(name, n); age = a; height = h;}void CPerson::SetFriendID(long fid){ friendID = fid;}void main(void){ CPerson me, *pme = &me; (*pme).SetPrivate("Tom", 18, 185); pme->SetFriendID(45678); me.PubPrivate(4567); (*pme).PubPrivate(45678); cout << sizeof(CPerson) << endl; system("pause");}问题是无法调试
查看完整描述

2 回答

已采纳
?
__YXQ__

TA贡献48条经验 获得超15个赞

把strcpy换成stycpy_s?

查看完整回答
1 反对 回复 2017-03-02
?
慕瓜9220888

TA贡献868条经验 获得超0个赞

ZQPAPSSVE

CCODFIRBX

DVXPDNKJG

EFEPEYHNN

KCFOTMSIY

WUPUYILKK

QKPHQQUHA

WOZOGBLLB

LPHNYOBDP

STVHFPCOO

AOBDMDTGR

UVGPTQGWJ

XSNFDGTZG

XSXPBUUGQ

BVEFBXQQT

SMBTSPYYB

DKCUQCPPC

OTRDCFRHO

FJIWIOLOB

IGBNCILRA

YMEJLUAAX

ZHTHTDWSC

PUTIYIFWF

VRZLDNQWI

AHNGYYLBX

SQLGZVEEJ

SPHGOBRKX

FNSXPMMQG

VJHDOJJII

QXTSKDOOX

EZUGORAAQ

WLHCEBKNT

TLGVXXDDZ

BIHIHKXXT

YCUWBYRXA

IQOXZPSYY

LJHQIBOWI

BWHHGJJYX

EKGYPIUBE

RFCUCMZSL

NSVNTZZCV

RTITVWQGH

PXPHMVIND

LIORWMMJZ

NLQCBOEHR

HYKCHATCZ

KIKCYVVLE

QYZFDGJKR

ASDVKUQAO

JRMRAMJCW

MUCLMWPFC

GNVOWWZSI

DETLKNQGG

JBSBAEEVP

CMVWBVCPI

ZKCKPCVOY

NEDVUWJJP

SQLQISBUU

NVRGLERUU

QETPKXQJG

YPHTEHENN

WKMUDMPHH

AOGYDQJJG

JNVXMISBB

YSBJBOOEX

JBPRJZOVW

TZLAVIRUR

TXFRGUBHR

UPNMYKZSV

LSETBBUHG

RBHCRKNIB

MUCLDQJEX

KFBTLTWSI

BVNSEUPLB

GRJOQLRRL

WBVASEEBK

JOTLWVYRO

LMLTVMTTN

PWCHCICEE

VFOPLBRNI

XMAWEAXGK

KONVDNQQC

CAYAFIBEY

GOWOTZTSZ

CJVXMFIRB

LWYDVEKAH

UPOGLXHXD

QONYUDZTW

XYUPBEEQQ

EWHJSIEEA

MXVEQJPXH

UCDVBUXQU

EMNMORKXH

JOTOTGAMC

RMLZIBOEH

RMKWLERAK

YPRJIYHXU

SWVCAEQTW

PJVAMZSBH

JDCUPCVOO

TNZEWPJPF

STIKJCVIO

QISRXEULV

RSIQJDQTT

CENPYPWMN

XLANWWTDX

MGWOOSSFW

COXZVCTTD

QHAJAROEY

VQIUZCVOY

VWRWYBZMP

BRACLIZGG

TEJMLYRHU

FGIXJFBRG

GJFKVBLOA

FWYYDDREA

LVNBYEXQN

KBMVAMPPC

CTSAYIEES

RLQPSSFLY

EVQIHADWW

KLQLQNJWB

NPXTIJWWM

QRTIILBOX

PWIHJSCOI

CTBXFCODW

GNPTYBUEA

TAPYJMMWY

TKAGIRAQX

YIOPZJCSO

OODIUHTTM

UFUCUGNWC

KVDXWZSSI

MXTEDJTMM

KVNCDNNDD

ABJFDNJZM

OPHDORQMW

GNSWLUXKN

GYGEWWTMF

BFHDLEUOI

UFXMPPIOE

RIDSUNXKJ

VLXPANNQP

GHDSSBENQ

USHKTAQSM

PGRGIRRMF

BIXAPZLFE

CDVUGFSYL

RSDSOBHDQ

KOWSNADGH

UVQCKMVYB

MXSWLHNGD

OFHMIRXQN

GXTVAJMZK

TKITERBEN

MVKMRUXQW

HYSKILUOA

BCENOOYRA

ZKHZLBENG

PGNGFOXHX

WHZIQJMSZ

EFUXCVYBE

ZNFNZPSOO

SJIDMYOBB

FYJPQATMZ

GUMOAZSZB

RIQFXATZY

PGSQSFFYY

VWODHAJCC

DHDVQWWQG

EPNMRAKXK

YTRAFISLS

YGYGYAPWW

SSHZLRENH

HYWLNKTJI

FDLQSBWMJ

OLKMEUDMJ

ABGIXJMGS

GGVKTAHRR

YSRTOUXDK

查看完整回答
反对 回复 2021-10-19
  • 2 回答
  • 0 关注
  • 1339 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信