首页 技术 正文
技术 2022年11月21日
0 收藏 429 点赞 4,012 浏览 1835 个字
#include <stdio.h>class aclass{
private:
int m;
char c;
public:
aclass(int i, char ch) {
printf("Constructor called.\n");
this->m = i;
this->c = ch;
}
~aclass() {//定义析构函数
printf("Destructor called.\n");
}
int getM() const {
return m;
}
void setM(int m) {
this->m = m;
}
char getC() const{
return c;
}
void setC(char c) {
this->c = c;
}
int add(int a, int b) {
printf("%d\n", a+b);
}
};int main(int argc, char* argv[]){
aclass *a = new aclass(3, 'c');
a->setM(5);
a->setC('a');
a->add(2, 8);
printf("%d\n", a->getM());
delete a;
return 0;
}
LOCAL_PATH := $(call my-dir)include $(CLEAR_VARS)LOCAL_ARM_MODE := arm
LOCAL_MODULE := cpp1
LOCAL_SRC_FILES := cpp1.cpp
include $(BUILD_EXECUTABLE)
text:00008600
.text:00008600
.text:00008600
.text:00008600 ; int __cdecl main(int argc, const char **argv, const char **envp)
.text:00008600 main ; CODE XREF: j_main↑j
.text:00008600 ; __unwind {
.text:00008600 PUSH {R4-R6,LR} ; 保存现场
.text:00008604 MOV R0, #8 ; unsigned int
.text:00008608 BL _Znwj ; 调用new 创建一个8字节的内存区域
.text:0000860C MOV R4, R0
.text:00008610 LDR R0, =(aConstructorCal - 0x8620) ; "Constructor called"的偏移
.text:00008614 LDR R5, =(aD - 0x862C) ; “%d\n”的偏移
.text:00008618 ADD R0, PC, R0 ; 获取“Constructor called" 首地址
.text:0000861C BL puts ; 打印“Constructor called”
.text:00008620 MOV R3, #5
.text:00008624 ADD R5, PC, R5 ; 获取“%d\n”字符串首地址
.text:00008628 STR R3, [R4] ; 把R3的值5,保存到R4对象的前四个字节
.text:0000862C MOV R3, #0x61 ; 'a'
.text:00008630 STRB R3, [R4,#4] ; 把R3的值a,保存到R4所指对象的后四个字节
.text:00008634 MOV R1, #0xA ; R1 = 10,这里编译器直接优化2+8为10
.text:00008638 MOV R0, R5 ; format
.text:0000863C BL printf ; 传入R0 和R1 分别是 “%d\n" 和10
.text:00008640 LDR R1, [R4] ; R1 = 5对象的前四个字节,即字段m的值
.text:00008644 MOV R0, R5 ; format
.text:00008648 BL printf ; printf 两个入参 R0 R1
.text:0000864C LDR R0, =(aDestructorCall - 0x8658) ; "Destructor called."
.text:00008650 ADD R0, PC, R0 ; 获取“Destructor called" 首地址
.text:00008654 BL puts ; 打印,一个参数编译器会把printf优化为puts
.text:00008658 MOV R0, R4 ; void *
.text:0000865C BL _ZdlPv ; _Zdlpv 为系统调用删除对象 ,R0为对象首地址
.text:00008660 MOV R0, #0
.text:00008664 POP {R4-R6,PC} ; 恢复现场
.text:00008664 ; End of function main
.text:00008664
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,996
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,510
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,353
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,137
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,770
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,848