Click here to Skip to main content
15,902,635 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
QuestionStatus window in DLL Pin
mparent12-Sep-06 11:45
mparent12-Sep-06 11:45 
Questionlistview and columns Pin
aguest12-Sep-06 11:26
aguest12-Sep-06 11:26 
QuestionReferenced namespace in another project not linking Pin
Klempie12-Sep-06 2:49
Klempie12-Sep-06 2:49 
QuestionMaking a dot net wrapper [modified] Pin
User 58385211-Sep-06 15:25
User 58385211-Sep-06 15:25 
AnswerRe: Making a dot net wrapper Pin
User 58385211-Sep-06 19:50
User 58385211-Sep-06 19:50 
QuestionTree View Control Pin
LakshmiPathiRao10-Sep-06 21:52
LakshmiPathiRao10-Sep-06 21:52 
AnswerRe: Tree View Control Pin
shezh12-Sep-06 5:25
shezh12-Sep-06 5:25 
QuestionStrange template behaviour? [modified] Pin
Zigenstein10-Sep-06 19:59
Zigenstein10-Sep-06 19:59 
Hi All,

I've started a new application and I'm trying to keep it all C++/CLI based as opposed to MFC - as much for the exercise of getting to grips with the whole world of .NET as anything else.

I've tried to create a very simple "Singleton" class template with the following code in a "Class Library":

// singleton.h
template <class T>
public ref class Singleton
{
public:
static T^ Instance()
{
if ( nullptr == m_hInstance )
{
m_hInstance = gcnew T;
}
return m_hInstance;
}

private:
static T^ m_hInstance = nullptr;
};


//somefile.h
namespace A
{
public ref class B : public Singleton<A::B>
{
// some stuff in here, constructor/destructor kept private
};
};


In a separate "Windows Forms" application, I *try* use the following line:
A::B^ hTheThing = A::B::Instance();

...for some reason, it tells me that "Instance is not a member of A::B".

Now, if I comment out the "template" line and replace all instances of "T" with "int" in the "singleton.h" file, the following line works fine:
int^ hTheThing = A::B::Instance();

If I reinstate the "template" line but make no reference to "T" in the template body (ie: leave it all as int-based), the problem resurfaces.

Clearly I'm doing something wrong, but what exactly that is, I have no idea. Any guidance would be appreciated.

Thanks
Zyrus




Ummm... yay...


-- modified at 19:26 Monday 11th September, 2006
AnswerRe: Strange template behaviour? [modified] Pin
George L. Jackson13-Sep-06 15:36
George L. Jackson13-Sep-06 15:36 
Questionstrange behaviour!!!!!!!!! Pin
hadez80310-Sep-06 13:02
hadez80310-Sep-06 13:02 
AnswerRe: strange behaviour!!!!!!!!! Pin
bob1697210-Sep-06 14:20
bob1697210-Sep-06 14:20 
Questiontic-tac-toe Pin
SwatiPathania10-Sep-06 5:50
SwatiPathania10-Sep-06 5:50 
AnswerRe: tic-tac-toe Pin
toxcct10-Sep-06 6:47
toxcct10-Sep-06 6:47 
QuestionHow can I make an editor, using C++? Pin
SwatiPathania10-Sep-06 5:49
SwatiPathania10-Sep-06 5:49 
QuestionSeeking hands Pin
kcynic8-Sep-06 21:40
kcynic8-Sep-06 21:40 
AnswerRe: Seeking hands Pin
toxcct10-Sep-06 6:50
toxcct10-Sep-06 6:50 
QuestionVC++ Express and GTK+ Pin
delphidab8-Sep-06 14:21
delphidab8-Sep-06 14:21 
QuestionReturn value from a function Pin
ankit_cse8-Sep-06 11:33
ankit_cse8-Sep-06 11:33 
AnswerRe: Return value from a function Pin
Jun Du9-Sep-06 5:07
Jun Du9-Sep-06 5:07 
GeneralRe: Return value from a function Pin
ankit_cse10-Sep-06 15:37
ankit_cse10-Sep-06 15:37 
Questiondynamically loading an unmanaged dll Pin
shezh8-Sep-06 7:13
shezh8-Sep-06 7:13 
AnswerRe: dynamically loading an unmanaged dll Pin
Jun Du8-Sep-06 7:27
Jun Du8-Sep-06 7:27 
AnswerRe: dynamically loading an unmanaged dll Pin
Nish Nishant8-Sep-06 8:08
sitebuilderNish Nishant8-Sep-06 8:08 
QuestionISO 9660 (Joliet) sector vise information Pin
vikasworks7-Sep-06 3:48
vikasworks7-Sep-06 3:48 
QuestionSendOrPostCallback issue Pin
HumanTargetJoe6-Sep-06 0:56
HumanTargetJoe6-Sep-06 0:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.