|
-
July 11th, 2002, 09:55 AM
#1
template
I have a template class as follows:
I would like to make it a singelton class;
I did some thing as follows:,But It is showing me errors...
template<class _base>
class Writer ublic _base
{
public:
}
static Writer<_base>* Instance();
};
template<class _base>
Writer<_base>* Writer<_base>::Instance()
{
static WriterThread<_base> theWriter();
return &theWriter;
}
Is it right?
Thanks in advance
-
July 11th, 2002, 10:08 AM
#2
Re: template
At first glance.
Code:
template<class _base>
class Writer : public _base
{
public:
} // syntax error
static Writer<_base>* Instance();
};
template<class _base>
Writer<_base>* Writer<_base>::Instance()
{
static WriterThread<_base> // WriterThread should be Writer
theWriter(); // function declaration, not constructor
return &theWriter;
}
Regards,
ZDF
What is good is twice as good if it's simple.
"Make it simple" is a complex task.
-
July 11th, 2002, 10:12 AM
#3
No compile errors with some changes:
Code:
template<class _base>
class Writer : public _base
{
public:
static Writer<_base>* Instance()
{
return theWriter;
}
private:
static Writer<_base>* theWriter;
};
Is this what you're looking for?
Jeff
-
July 11th, 2002, 10:55 AM
#4
Please don't post the same message on multiple forums. It's very annoying. I really hate to see something I answered already answered on another forum. I feel you've just wasted my time.
Jeff
-
July 11th, 2002, 11:03 AM
#5
Iam Really sorry for that.Iam posting on multiple forums, to make sure that everyone sees it & to definetly get a reply back.
Once again Iam sorry for the inconvenience that it caused you.
-
July 11th, 2002, 11:11 AM
#6
At the very least, if you just can't resist, you should wait a bit before posting to the other forum.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|