V
Vincent RICHOMME
Hi,
First my questions are related to C++ even if I am talking about managed
c++(.NET)...
I am currently implementing some interesting .NET classes in c++(native
code) and I am not an expert with static methods.
Here is what I am doing (class to manage processes) :
..h
#include <vector>
using namespace std;
namespace System{
namespace Diagnostics{
class ProcessStartInfo
{
public:
friend class Process;
ProcessStartInfo();
protected:
PROCESS_INFORMATION m_sProcessinfo;
};
class Process
{
public:
Process(void);
~Process(void);
public:
//static vector<Process> GetProcesses();
static void Start(LPCTSTR tszName);
//void Start(ProcessStartInfo& procinfo);
CString GetProcessName();
DWORD GetId();
protected:
static ProcessStartInfo m_ProcessStartInfo;
};
} //Diagnostics
} //System
//-------------------------------------------------------------------
..cpp
#include "SystemDiagnosticsProcess.h"
#include "Tlhelp32.h"
namespace System{
namespace Diagnostics{
ProcessStartInfo:rocessStartInfo()
{
memset(&m_sProcessinfo, 0, sizeof(m_sProcessinfo) );
}
Process:rocess(void){}
Process::~Process(void){}
/*static*/
void Process::Start(LPCTSTR tszName)
{
BOOL bRet = CreateProcess(tszName,
NULL,
NULL,
NULL,
FALSE,
0,
NULL,
NULL,
NULL,
&(m_ProcessStartInfo.m_sProcessinfo) );
}
} // Diagnostics
} // System
//-----------------------------------------------------------------
When I compile I get :
unresolved external symbol "protected: static class
System:iagnostics:rocessStartInfo
System:iagnostics:rocess::m_ProcessStartInfo"
(?m_ProcessStartInfo@Process@Diagnostics@System@@1VProcessStartInfo@23@A
How should I fix this.
Another question is, in managed c++ you can do :
array<Process^>^localAll = Process::GetProcesses();
I would like to do the same, I suppose(not sure)that I should declare in
my class a vector<Process*> and rename it as Array<Process>.
I tried to rename it via a typdef but it doesn't work and in addition if
I create a System::Test::MyClass with a method returning a
vector<MyClass*> I will have to do it again.
How can I declare a global class(seen in all my namespaces) called Array
and that takes pointer on object.
First my questions are related to C++ even if I am talking about managed
c++(.NET)...
I am currently implementing some interesting .NET classes in c++(native
code) and I am not an expert with static methods.
Here is what I am doing (class to manage processes) :
..h
#include <vector>
using namespace std;
namespace System{
namespace Diagnostics{
class ProcessStartInfo
{
public:
friend class Process;
ProcessStartInfo();
protected:
PROCESS_INFORMATION m_sProcessinfo;
};
class Process
{
public:
Process(void);
~Process(void);
public:
//static vector<Process> GetProcesses();
static void Start(LPCTSTR tszName);
//void Start(ProcessStartInfo& procinfo);
CString GetProcessName();
DWORD GetId();
protected:
static ProcessStartInfo m_ProcessStartInfo;
};
} //Diagnostics
} //System
//-------------------------------------------------------------------
..cpp
#include "SystemDiagnosticsProcess.h"
#include "Tlhelp32.h"
namespace System{
namespace Diagnostics{
ProcessStartInfo:rocessStartInfo()
{
memset(&m_sProcessinfo, 0, sizeof(m_sProcessinfo) );
}
Process:rocess(void){}
Process::~Process(void){}
/*static*/
void Process::Start(LPCTSTR tszName)
{
BOOL bRet = CreateProcess(tszName,
NULL,
NULL,
NULL,
FALSE,
0,
NULL,
NULL,
NULL,
&(m_ProcessStartInfo.m_sProcessinfo) );
}
} // Diagnostics
} // System
//-----------------------------------------------------------------
When I compile I get :
unresolved external symbol "protected: static class
System:iagnostics:rocessStartInfo
System:iagnostics:rocess::m_ProcessStartInfo"
(?m_ProcessStartInfo@Process@Diagnostics@System@@1VProcessStartInfo@23@A
How should I fix this.
Another question is, in managed c++ you can do :
array<Process^>^localAll = Process::GetProcesses();
I would like to do the same, I suppose(not sure)that I should declare in
my class a vector<Process*> and rename it as Array<Process>.
I tried to rename it via a typdef but it doesn't work and in addition if
I create a System::Test::MyClass with a method returning a
vector<MyClass*> I will have to do it again.
How can I declare a global class(seen in all my namespaces) called Array
and that takes pointer on object.