destruct.cpp

  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>
#include <iomanip.h>
#include <string.h>

class Book
{
  public:
    char title[256];
    char author[64];
    float price;
    Book(char *title, char *author, char *publisher, float price);
    ~Book(void);
    void show_title(void) { cout << title << '/n'; };
    float get_price(void) { return(price); };
    void show_book(void)
    {
      show_title();
      show_publisher();
    };
    void assign_publisher(char *name) { strcpy(publisher, name); };
  private:
    char publisher[256];
    void show_publisher(void) { cout << publisher << '/n'; };
};

Book::Book(char *title, char *author, char *publisher, float price)
 {
   strcpy(Book::title, title);
   strcpy(Book::author, author);
   strcpy(Book::publisher, publisher);
   Book::price = price;
 }

Book::~Book(void)
 {
   cout << "Destructing the instance " << title << '/n';
 }

void main(void)
 {
   Book tips("Jamsa's C/C++ Programmer's Bible", "Jamsa and Klander",
    "Jamsa Press", 49.95);
   Book diary("All My Secrets...", "Kris Jamsa", "None", 9.95);

   tips.show_book();
   diary.show_book();
 }

 

a.cpp: In copy constructor ‘COMPUTER::COMPUTER(const COMPUTER&)’: a.cpp:138:40: error: binding reference of type ‘CPU&’ to ‘const CPU’ discards qualifiers 138 | COMPUTER(const COMPUTER& a) : cp(a.cp), r(a.r), cd(a.cd) | ~~^~ a.cpp:21:14: note: initializing argument 1 of ‘CPU::CPU(CPU&)’ 21 | CPU(CPU& a) | ~~~~~^ a.cpp:138:49: error: binding reference of type ‘RAM&’ to ‘const RAM’ discards qualifiers 138 | COMPUTER(const COMPUTER& a) : cp(a.cp), r(a.r), cd(a.cd) | ~~^ a.cpp:67:14: note: initializing argument 1 of ‘RAM::RAM(RAM&)’ 67 | RAM(RAM& a) | ~~~~~^ a.cpp:138:58: error: binding reference of type ‘CDORM&’ to ‘const CDORM’ discards qualifiers 138 | COMPUTER(const COMPUTER& a) : cp(a.cp), r(a.r), cd(a.cd) | ~~^~ a.cpp:102:18: note: initializing argument 1 of ‘CDORM::CDORM(CDORM&)’ 102 | CDORM(CDORM& a) | ~~~~~~~^ a.cpp: In member function ‘void COMPUTER::showinfo() const’: a.cpp:144:16: error: passing ‘const CPU’ as ‘this’ argument discards qualifiers [-fpermissive] 144 | cp.showinfo(); | ~~~~~~~~~~~^~ a.cpp:41:10: note: in call to ‘void CPU::showinfo()’ 41 | void showinfo() | ^~~~~~~~ a.cpp:145:15: error: passing ‘const RAM’ as ‘this’ argument discards qualifiers [-fpermissive] 145 | r.showinfo(); | ~~~~~~~~~~^~ a.cpp:77:10: note: in call to ‘void RAM::showinfo()’ 77 | void showinfo() | ^~~~~~~~ a.cpp:146:16: error: passing ‘const CDORM’ as ‘this’ argument discards qualifiers [-fpermissive] 146 | cd.showinfo(); | ~~~~~~~~~~~^~ a.cpp:112:10: note: in call to ‘void CDORM::showinfo()’ 112 | void showinfo() | ^~~~~~~~
11-15
[ RUN ] TestBusinessStateMachine.testForTest 2025-08-15 15:27:05 756.490 [126444125134976] [DEBUG] [/home/yushijin/fromGitLib/myWorkspace/20250813/rhc/src/source/entry/source/rh_entry.cpp:RHEntry:38] [Construct RHEntry ...] 2025-08-15 15:27:05 756.544 [126444125134976] [DEBUG] [/home/yushijin/fromGitLib/myWorkspace/20250813/rhc/src/source/entry/source/rh_entry.cpp:RHEntry:38] [Construct RHEntry ...] 2025-08-15 15:27:05 756.777 [126444125134976] [DEBUG] [/home/yushijin/fromGitLib/myWorkspace/20250813/rhc/mock/source/mock_rt_device_manager.cpp:~RTDeviceManager:99] [----test----device---destruct----] 2025-08-15 15:27:05 756.886 [126444125134976] [DEBUG] [/home/yushijin/fromGitLib/myWorkspace/20250813/rhc/src/source/controller/source/business_state_machine.cpp:DoRobotGetFromSmif:287] [State:RobotGetFromSmif,Substate:RH_INITIALIZE_SUBSTATE] 2025-08-15 15:27:05 757.046 [126444125134976] [DEBUG] [/home/yushijin/fromGitLib/myWorkspace/20250813/rhc/src/source/controller/source/business_state_machine.cpp:DoRobotGetFromSmif:300] [Load Reticle: From Smif ...] 2025-08-15 15:27:05 757.069 [126444125134976] [DEBUG] [/home/yushijin/fromGitLib/myWorkspace/20250813/rhc/src/source/controller/source/business_state_machine.cpp:AddState:2453] [RH: add state ,state:7, substate:16] 2025-08-15 15:27:05 757.089 [126444125134976] [DEBUG] [/home/yushijin/fromGitLib/myWorkspace/20250813/rhc/src/source/controller/source/business_state_machine.cpp:AddState:2453] [RH: add state ,state:7, substate:22] 2025-08-15 15:27:05 757.103 [126444125134976] [DEBUG] [/home/yushijin/fromGitLib/myWorkspace/20250813/rhc/src/source/controller/source/robot_module.cpp:RobotGetFromSmif:161] [State:RobotGetFromSmif,Substate:RH_INITIALIZE_SUBSTATE] Segmentation fault (core dumped)
08-16
a.cpp:8:5: error: ‘CPU’ does not name a type 8 | CPU cp; | ^~~ a.cpp:9:5: error: ‘RAM’ does not name a type 9 | RAM r; | ^~~ a.cpp:10:5: error: ‘CDORM’ does not name a type 10 | CDORM cd; | ^~~~~ a.cpp:24:10: error: extra qualification ‘COMPUTER::’ on member ‘showinfo’ [-fpermissive] 24 | void COMPUTER::showinfo() const | ^~~~~~~~ a.cpp: In constructor ‘COMPUTER::COMPUTER()’: a.cpp:12:16: error: class ‘COMPUTER’ does not have any field named ‘cp’ 12 | COMPUTER():cp(),r(),cd() | ^~ a.cpp:12:21: error: class ‘COMPUTER’ does not have any field named ‘r’ 12 | COMPUTER():cp(),r(),cd() | ^ a.cpp:12:25: error: class ‘COMPUTER’ does not have any field named ‘cd’ 12 | COMPUTER():cp(),r(),cd() | ^~ a.cpp: In constructor ‘COMPUTER::COMPUTER(int, double, double, int, int)’: a.cpp:17:11: error: class ‘COMPUTER’ does not have any field named ‘cp’ 17 | : cp(a, b, c), r(d), cd(e) { | ^~ a.cpp:17:24: error: class ‘COMPUTER’ does not have any field named ‘r’ 17 | : cp(a, b, c), r(d), cd(e) { | ^ a.cpp:17:30: error: class ‘COMPUTER’ does not have any field named ‘cd’ 17 | : cp(a, b, c), r(d), cd(e) { | ^~ a.cpp: In copy constructor ‘COMPUTER::COMPUTER(const COMPUTER&)’: a.cpp:20:35: error: class ‘COMPUTER’ does not have any field named ‘cp’ 20 | COMPUTER(const COMPUTER& a) : cp(a.cp), r(a.r), cd(a.cd) | ^~ a.cpp:20:40: error: ‘const class COMPUTER’ has no member named ‘cp’ 20 | COMPUTER(const COMPUTER& a) : cp(a.cp), r(a.r), cd(a.cd) | ^~ a.cpp:20:45: error: class ‘COMPUTER’ does not have any field named ‘r’ 20 | COMPUTER(const COMPUTER& a) : cp(a.cp), r(a.r), cd(a.cd) | ^ a.cpp:20:49: error: ‘const class COMPUTER’ has no member named ‘r’ 20 | COMPUTER(const COMPUTER& a) : cp(a.cp), r(a.r), cd(a.cd) | ^ a.cpp:20:53: error: class ‘COMPUTER’ does not have any field named ‘cd’ 20 | COMPUTER(const COMPUTER& a) : cp(a.cp), r(a.r), cd(a.cd) | ^~ a.cpp:20:58: error: ‘const class COMPUTER’ has no member named ‘cd’ 20 | COMPUTER(const COMPUTER& a) : cp(a.cp), r(a.r), cd(a.cd) | ^~ a.cpp: In member function ‘void COMPUTER::showinfo() const’: a.cpp:26:5: error: ‘cp’ was not declared in this scope 26 | cp.showinfo(); | ^~ a.cpp:27:5: error: ‘r’ was not declared in this scope 27 | r.showinfo(); | ^ a.cpp:28:5: error: ‘cd’ was not declared in this scope 28 | cd.showinfo(); | ^~这是修改后的代码以及终端输出#include<iostream> #include<string> using namespace std; class COMPUTER { private: CPU cp; RAM r; CDORM cd; public: COMPUTER():cp(),r(),cd() { cout<<"no para to create a COMPUTER!"<<endl; } COMPUTER(int a, double b, double c, int d, int e) : cp(a, b, c), r(d), cd(e) { cout << "create a COMPUTER with para!" << endl; } COMPUTER(const COMPUTER& a) : cp(a.cp), r(a.r), cd(a.cd) { std::cout << "create a COMPUTER by copy!" << std::endl; } void COMPUTER::showinfo() const { cp.showinfo(); r.showinfo(); cd.showinfo(); } ~COMPUTER() { cout << "destruct a COMPUTER!" << endl; } }; class CPU { private: int rank; double frequency; double voltage; public: //构造函数 CPU():rank(1),frequency(2),voltage(100) { cout<<"create a CPU!"<<endl; } CPU(int r,double f,double v):rank(r),frequency(f),voltage(v) { cout<<"create a CPU!"<<endl; } CPU(CPU& a) { rank=a.getRank(); frequency=a.getFrequency(); voltage=a.getVoltage(); cout<<"create a CPU by copy!"<<endl; } //get函数 int getRank() { return rank; } double getFrequency() { return frequency; } double getVoltage() { return voltage; } void showinfo() { cout<<"cpu parameter:"<<endl; cout<<"rank:"<<rank<<endl; cout<<"frequency:"<<frequency<<endl; cout<<"voltage:"<<voltage<<endl; } ~CPU()//析构函数 { cout<<"destruct a CPU!"<<endl; } }; class RAM { private: int size; public: //构造函数 RAM():size(1) { cout<<"create a RAM!"<<endl; } RAM(int s):size(s) { cout<<"create a RAM!"<<endl; } RAM(RAM& a) { size=a.getSize(); cout<<"create a RAM by copy!"<<endl; } //get函数 int getSize() { return size; } void showinfo() { cout<<"ram parameter:"<<endl; cout<<"volumn:"<<size<<" GB"<<endl; } ~RAM()//析构函数 { cout<<"destruct a RAM!"<<endl; } }; class CDORM { private: int speed; public: //构造函数 CDORM():speed(16) { cout<<"create a CDROM!"<<endl; } CDORM(int s):speed(s) { cout<<"create a CDROM!"<<endl; } CDORM(CDORM& a) { speed=a.getSpeed(); cout<<"create a CDROM by copy!"<<endl; } //get函数 int getSpeed() { return speed; } void showinfo() { cout<<"cdrom parameter:"<<endl; cout<<"speed:"<<speed<<endl; } ~CDORM()//析构函数 { cout<<"destruct a CDROM!"<<endl; } };
11-15
[==========] Running 77 tests from 2 test suites. [----------] Global test environment set-up. [----------] 1 test from TestRHZmqCommunication [ RUN ] TestRHZmqCommunication.testCommunication 2025-08-15 15:04:17 794.824 [132287390417024] [DEBUG] [/home/yushijin/fromGitLib/myWorkspace/20250813/rhc/tests/include/test_rh_zmq_communication.h:TestRHZmqCommunication:32] [Construct Start...] 2025-08-15 15:04:17 794.992 [132287390417024] [DEBUG] [/home/yushijin/fromGitLib/myWorkspace/20250813/rhc/src/source/entry/source/rh_entry.cpp:RHEntry:38] [Construct RHEntry ...] 2025-08-15 15:04:17 795.036 [132287390417024] [DEBUG] [/home/yushijin/fromGitLib/myWorkspace/20250813/rhc/tests/include/test_rh_zmq_communication.h:TestRHZmqCommunication:37] [Construct end...] 2025-08-15 15:04:17 795.068 [132287390417024] [DEBUG] [/home/yushijin/fromGitLib/myWorkspace/20250813/rhc/tests/include/test_rh_zmq_communication.h:SetUp:48] [ Set Up Start...] 2025-08-15 15:04:17 795.096 [132287390417024] [DEBUG] [/home/yushijin/fromGitLib/myWorkspace/20250813/rhc/src/source/entry/source/rh_entry.cpp:RHEntry:38] [Construct RHEntry ...] yaml file not exist:/home/yaoyedong/rhc/mw_config.yaml 2025-08-15 15:04:17 795.491 [132287390417024] [ERROR] [/home/xuejibao/version_zmq/basiclibrary/bneyaml/src/bne_yaml.cpp:BNEYamlInit:59] [yaml file not exist: /home/yaoyedong/rhc/mw_config.yaml ] 2025-08-15 15:04:17 795.546 [132287390417024] [ERROR] [/home/yushijin/fromGitLib/myWorkspace/20250813/rhc/src/zmq/src/rh_server.cpp:RHServerInit:65] [BNEYamlInit failed [ef000011]] 2025-08-15 15:04:17 795.581 [132287390417024] [ERROR] [/home/yushijin/fromGitLib/myWorkspace/20250813/rhc/tests/include/test_rh_zmq_communication.h:SetServerInitialize:82] [RHRegisterCallback ServerInit failed] 2025-08-15 15:04:17 795.627 [132287390417024] [DEBUG] [/home/yushijin/fromGitLib/myWorkspace/20250813/rhc/mock/source/mock_rt_device_manager.cpp:~RTDeviceManager:99] [----test----device---destruct----] 2025-08-15 15:04:17 795.667 [132287390417024] [DEBUG] [/home/yushijin/fromGitLib/myWorkspace/20250813/rhc/tests/include/test_rh_zmq_communication.h:SetUp:52] [ Set Up End...] 2025-08-15 15:04:17 795.704 [132287390417024] [DEBUG] [/home/yushijin/fromGitLib/myWorkspace/20250813/rhc/mock/source/mock_rt_device_manager.cpp:~RTDeviceManager:99] [----test----device---destruct----] [ OK ] TestRHZmqCommunication.testCommunication (0 ms) [----------] 1 test from TestRHZmqCommunication (0 ms total) [----------] 76 tests from TestBusinessStateMachine [ RUN ] TestBusinessStateMachine.testDoRobotGetFromSmif 2025-08-15 15:04:17 796.174 [132287390417024] [DEBUG] [/home/yushijin/fromGitLib/myWorkspace/20250813/rhc/src/source/entry/source/rh_entry.cpp:RHEntry:38] [Construct RHEntry ...] 2025-08-15 15:04:17 796.251 [132287390417024] [DEBUG] [/home/yushijin/fromGitLib/myWorkspace/20250813/rhc/src/source/entry/source/rh_entry.cpp:RHEntry:38] [Construct RHEntry ...] 2025-08-15 15:04:17 796.453 [132287390417024] [DEBUG] [/home/yushijin/fromGitLib/myWorkspace/20250813/rhc/mock/source/mock_rt_device_manager.cpp:~RTDeviceManager:99] [----test----device---destruct----] 2025-08-15 15:04:17 796.580 [132287390417024] [DEBUG] [/home/yushijin/fromGitLib/myWorkspace/20250813/rhc/src/source/controller/source/business_state_machine.cpp:DoRobotGetFromSmif:287] [State:RobotGetFromSmif,Substate:RH_INITIALIZE_SUBSTATE] 2025-08-15 15:04:17 796.760 [132287390417024] [DEBUG] [/home/yushijin/fromGitLib/myWorkspace/20250813/rhc/src/source/controller/source/business_state_machine.cpp:DoRobotGetFromSmif:300] [Load Reticle: From Smif ...] 2025-08-15 15:04:17 796.814 [132287390417024] [DEBUG] [/home/yushijin/fromGitLib/myWorkspace/20250813/rhc/src/source/controller/source/business_state_machine.cpp:AddState:2453] [RH: add state ,state:7, substate:16] 2025-08-15 15:04:17 796.853 [132287390417024] [DEBUG] [/home/yushijin/fromGitLib/myWorkspace/20250813/rhc/src/source/controller/source/business_state_machine.cpp:AddState:2453] [RH: add state ,state:7, substate:22] 2025-08-15 15:04:17 796.890 [132287390417024] [DEBUG] [/home/yushijin/fromGitLib/myWorkspace/20250813/rhc/src/source/controller/source/robot_module.cpp:RobotGetFromSmif:161] [State:RobotGetFromSmif,Substate:RH_INITIALIZE_SUBSTATE] /home/yushijin/fromGitLib/myWorkspace/20250813/rhc/tests/unit_src/test_business_state_machine.cpp:158: Failure Actual function call count doesn't match EXPECT_CALL(*mockRobotModule_, RobotGetFromSmif(testing::_,testing::_))... Expected: to be called once Actual: never called - unsatisfied and active 2025-08-15 15:04:17 797.058 [132287390417024] [DEBUG] [/home/yushijin/fromGitLib/myWorkspace/20250813/rhc/src/source/controller/source/business_state_machine.cpp:DoRobotGetFromSmif:287] [State:RobotGetFromSmif,Substate:RH_ROBOTT_MOVE_TO_HOMET_SUBSTATE] 2025-08-15 15:04:17 797.107 [132287390417024] [ERROR] [/home/yushijin/fromGitLib/myWorkspace/20250813/rhc/src/source/controller/source/business_state_machine.cpp:DoRobotGetFromSmif:349] [Smif Or Robot Material Error ...] 2025-08-15 15:04:17 797.143 [132287390417024] [DEBUG] [/home/yushijin/fromGitLib/myWorkspace/20250813/rhc/src/source/controller/source/robot_module.cpp:RobotGetFromSmif:161] [State:RobotGetFromSmif,Substate:RH_ROBOTT_MOVE_TO_HOMET_SUBSTATE] Segmentation fault (core dumped)
08-16
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值