1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
#pragma once
class
_declspec(
dllexport
) NativeClass
{
private
:
int
nCount;
public
:
NativeClass(
void
)
{
this
->nCount = 0;
}
~NativeClass(
void
)
{
}
int
GetCount(
void
)
{
return
this
->nCount;
}
void
Increase(
void
)
{
this
->nCount++;
}
void
Clear(
void
)
{
this
->nCount = 0;
}
};
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
// ManageClass.h
#pragma once
#include "NativeClass.h"
using
namespace
System;
namespace
ManageClass {
public
ref
class
NativeClassEx
{
// TODO: 在此处添加此类的方法。
private
:
NativeClass * m_pnClass;
public
:
NativeClassEx(
void
)
{
this
->m_pnClass =
new
NativeClass();
}
~NativeClassEx(
void
)
{
delete
this
->m_pnClass;
}
int
GetCount(
void
)
{
return
this
->m_pnClass->GetCount();
}
void
Increase(
void
)
{
this
->m_pnClass->Increase();
}
void
Clear(
void
)
{
this
->m_pnClass->Clear();
}
protected
:
!NativeClassEx(
void
)
{
delete
this
->m_pnClass;
}
};
}
|
1
2
3
4
5
6
7
8
|
NativeClassEx testCalss =
new
NativeClassEx();
Debug.WriteLine(
"GetCount : "
+ testCalss.GetCount().ToString());
testCalss.Increase();
testCalss.Increase();
testCalss.Increase();
Debug.WriteLine(
"GetCount : "
+ testCalss.GetCount().ToString());
testCalss.Clear();
Debug.WriteLine(
"GetCount : "
+ testCalss.GetCount().ToString());
|