creating limited objects
-
// Create only 3 objects in class demo.
#include
static int nCount = 0;
class Demo
{
public:
Demo()
{
nCount++;
}
};bool IsMax()
{
if(nCount>3)
return true;
else
return false;
}int main()
{
// here is 4 objects.
Demo d1,d2,d3,d4;
if(IsMax())
{
cout<<"error"< -
I've never even heard of a "tripleton" class, and we have two different people wanting it within hours of each other? http://www.codeproject.com/Messages/3229571/Class-Object.aspx[^] Maybe you should speak with your classmate / colleague and collaborate. His question has answers too. Iain.
I have now moved to Sweden for love (awwww). If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), or need contract work done, give me a job! http://cv.imcsoft.co.uk/[^]
-
If you don't stop using multiple logins to ask the same stupid queries, I'll take it to the admin to have all your logins banned. I remember warning you once already. :|
It is a crappy thing, but it's life -^ Carlo Pallini
-
-
// Create only 3 objects in class demo.
#include
static int nCount = 0;
class Demo
{
public:
Demo()
{
nCount++;
}
};bool IsMax()
{
if(nCount>3)
return true;
else
return false;
}int main()
{
// here is 4 objects.
Demo d1,d2,d3,d4;
if(IsMax())
{
cout<<"error"<Why don't you keep your wonderful techniques secret? :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
If you don't stop using multiple logins to ask the same stupid queries, I'll take it to the admin to have all your logins banned. I remember warning you once already. :|
It is a crappy thing, but it's life -^ Carlo Pallini
Rajesh R Subramanian wrote:
If you don't stop using multiple logins
He's asking for Singleton-like patters just for limiting his logins... :-D
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
p_1960 wrote:
...how can i restrict the class to do the same...
By reading here.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons