当前位置:网站首页 > 技术博客 > 正文

c++结构体简单例子



 1 int main(){  2  3 MyTree *t1 = new MyTree(1);  4 MyTree *t2 ;  5 t2->val = 2;  6 cout<<t1->val<<" "<<t2->val; //输出:1 2  7 t2.val = 3; //error: request for member 'val' in 't2', whitch is of pointer type 'MyTree*' (maybe you meant to use '->' ?)  8 cout<<t2.val; //error: request for member 'val' in 't2', which is of pointer type 'MyTree*' (maybe you mean to use '->' ?  9 return 0; 10 }

版权声明


相关文章:

  • offsetof函数用法2024-11-04 08:30:01
  • 爬虫中的url是什么2024-11-04 08:30:01
  • 计算机专业简历介绍2024-11-04 08:30:01
  • python做预测模型2024-11-04 08:30:01
  • html中img标签的作用2024-11-04 08:30:01
  • unittest(unittest.mock --- 新手入门¶)2024-11-04 08:30:01
  • 积分运算电路和微分运算电路2024-11-04 08:30:01
  • 激活函数swish2024-11-04 08:30:01
  • 多网卡bond后网络不通2024-11-04 08:30:01
  • kvm虚拟机下载2024-11-04 08:30:01