STL的小程序,高手不必看了。

nuistbaker 2008-04-14 11:07:14
// STL学习2.cpp: 主项目文件。

#include "stdafx.h"

using namespace System;

template <class T>
inline const T& max(const T& a,const T& b )
{
return a>b?a:b;
}

int main(array<System::String ^> ^args)
{
Console::WriteLine(L"Hello World");
int imax;
imax=max(12,14);

Console::WriteLine(imax);

Console::ReadKey();
return 0;
}
...全文
161 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
nuistbaker 2008-04-15
  • 打赏
  • 举报
回复
我的代码都是编译能通过,运行有结果的饿。。。难道不对吗?
nuistbaker 2008-04-15
  • 打赏
  • 举报
回复
在学习STL,自己写的代码,练习下,不想惊动了3颗星的。。。我这是2005的C++
nuistbaker 2008-04-15
  • 打赏
  • 举报
回复
// STL学习2.cpp: 主项目文件。

#include "stdafx.h"

using namespace System;

template <class T>
inline const T& max(const T& a,const T& b )
{
return a>b?a:b;
}

template <class T>
class Myclass{
public:
typename T::Subtype *ptr;
};

class Q
{
public:
typedef int Subtype;
};



int main(array<System::String ^> ^args)
{
Console::WriteLine(L"Hello World");
//1
int imax;
imax=max(12,14);

//2
Myclass<Q> *x=new Myclass<Q>();
int* iptr;
int i=19;
iptr=&i;

x->ptr=iptr;

Console::WriteLine(*iptr);
Console::WriteLine(*x->ptr);

Console::ReadKey();
return 0;
}
z_kris 2008-04-15
  • 打赏
  • 举报
回复
我不是高手 所以来看看
nuistbaker 2008-04-15
  • 打赏
  • 举报
回复
我是用2005 C++速成版写的代码,怎么会是C#呢,晕哦。
icosagon 2008-04-15
  • 打赏
  • 举报
回复
ms自家的c++
taodm 2008-04-15
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 nuistbaker 的回复:]
我的代码都是编译能通过,运行有结果的饿。。。难道不对吗?
[/Quote]
不是代码对不对的问题,而是你发错论坛的问题。
你在讨论的不是C++代码。要么去C#版,要么你学学真正的C++。
yuyunliuhen 2008-04-15
  • 打赏
  • 举报
回复
咦。。。不懂
sun3411 2008-04-14
  • 打赏
  • 举报
回复
托管c++.... 呵呵
effective_person 2008-04-14
  • 打赏
  • 举报
回复
晕了!一看怎么就没见过啊!失败了!
taodm 2008-04-14
  • 打赏
  • 举报
回复
你还是去C#版问吧。你现在的代码,C++高手也不会。

65,210

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧