++ CLR中的标头和cpp文件 [英] header and cpp files in ++ CLR

查看:110
本文介绍了++ CLR中的标头和cpp文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

我想知道何时创建基于C ++ CLI的程序,然后如何进行编码
在.cpp和.h文件中

就像在vc6中
我用户


//在此,我只在类内部声明函数

test.h

HI all

i want to know when i create C++ CLI based program then how to do coding
in .cpp and .h files

like in vc6
i user


// in this i just declare function inside the class

test.h

class testone
{
// function declare
void hellow(int one);
int two(int a ,int b)
};


//在cp中,我给出了函数的定义
test.cpp


// in cp i give the definition of functions
test.cpp

void testone::hellow(int one)
{

.... do some work
}

int testone::two(int a,int b)
{

do some operation ...
}



//在其他.cpp文件中使用这些文件
//variant.cpp

#include"test.h"

//现在,如果我想使用test.h函数
//创建test.h类的对象



// use of these files in other .cpp files
// variant.cpp

#include "test.h"

// now if i want to use test.h functions
//create object of class of test.h

testone testoneObj;

 testoneObj.two(2,5);
 testoneObj.hellow(argu);


如何在.net中的c ++的CLR中做到所有这些
如果我在CLR IN .CPP文件中给出定义,则会给我错误
它也不使用::来使类在头文件中访问其功能
请帮忙怎么做

关于


how to do this all in CLR of c++ in .net
if i give definition in CLR IN .CPP files it gives me error
it also not use :: for the class to acces its functions in header file
plz help how to do this

Regards

推荐答案

在这里,尝试过一次...

简而言之-算了吧.这是将C ++程序员带入.Net的一种MS方法.

他们严重滥用了C ++,以至于现在(我相信)它已被弃用.

如果您确实需要编写.net应用,请使用C#.

但是,如果您确实需要使用C ++,则可以阅读,或
been here, tried it once...

In short - forget about it. It was a MS way to bring C++ programmers to .Net.

They abused the C++ so badly that it is now (I believe) deprecated.

If you really need to write a .net app, use C#.

However, if you really need to use C++, then read perhaps this, or this.

Basically, when you create a class like you did, it becomes a __gc class, nad needs to be initialised with gcnew operator.


这篇关于++ CLR中的标头和cpp文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆