| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2212 人关注过本帖
标题:类型运算符
取消只看楼主 加入收藏
FrankloveCyy
Rank: 1
等 级:新手上路
帖 子:33
专家分:0
注 册:2019-5-5
结帖率:11.11%
收藏
 问题点数:0 回复次数:2 
类型运算符
#include<iostream>
#include<memory>//new include to use unique_ptr
using namespace std;

class Date
{
private:
        int day, month, year;
        string dateInString;
        
public:
     Date(int inMonth,int inDay,int inYear)
        : month(inMonth), day(inDay), year(inYear){};
        
    void DisplayDate()
    {
        cout<< month << " / " << day << " / " << year <<endl;
    }        
};

int main()
{
    unique_ptr<int>smartIntPtr(new int);
    *smartIntPtr = 42;
   
    //Use smart pointer type like an int*
    cout<< "Integer value is: " << *smartIntPtr << endl;
   
    unique_ptr<Date>smartHoliday(new Date(12,25,2016));
    cout<<"The new instance of date contains: ";
   
    //use smartHoliday just as you would a Date*
    smartHoliday->DaisplayDate();
   
    return 0;
}
图片附件: 游客没有浏览图片的权限,请 登录注册

上面是编译器出的报错,代码明明和书上是一样的,出现报错一头雾水,有大神能给解惑一下吗?
搜索更多相关主题的帖子: new Date int year cout 
2019-07-24 13:22
FrankloveCyy
Rank: 1
等 级:新手上路
帖 子:33
专家分:0
注 册:2019-5-5
收藏
得分:0 
回复 2楼 rjsp
估计应该是下载时候DEV自带编译器的原始版本,没更新过
2019-07-26 11:28
FrankloveCyy
Rank: 1
等 级:新手上路
帖 子:33
专家分:0
注 册:2019-5-5
收藏
得分:0 
回复 2楼 rjsp
好像是4.9.2
2019-07-26 11:30
快速回复:类型运算符
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.035921 second(s), 10 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved