设为首页 加入收藏

TOP

自定义命名空间和使用(二)
2013-01-01 14:46:21 来源: 作者: 【 】 浏览:455
Tags:定义 命名 空间 使用

 

    3》自定义string.cpp

    [cpp]

    #include "StdAfx.h"

    #include "string.h"

    string::string(int id)

    {

    this->id=id;

    }

    int string::getId()

    {

    return id;

    }

    string::~string(void)

    {

    }

    4》TestWin32.cpp(控制台应用程序的入口)

    [cpp]

    // TestWin32.cpp : 定义控制台应用程序的入口点。

    //

    #include "stdafx.h"

    #include <string.h>//估计采用两个string来产生冲突

    #include "Student1.h"

    #include "string.h"

    #include <iostream>

    using namespace potter;

    void _tmain(int argc, _TCHAR* argv[])

    {

    string s(2);

    std::cout《s.getId()《std::endl;

    return;

    };

    5》运行结果:

    2

      

首页 上一页 1 2 下一页 尾页 2/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇C++使用localtime函数需注意 下一篇VC++查找替换对话框

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: