• C

Singleton pointer in C

I came across some document stating Singleton pointers in C
what is this any example ?
tittuAsked:
Who is Participating?
 
Infinity08Connect With a Mentor Commented:
>> array vs singleton pointer in coverity testing described in C please eloborate this

In that case, I think it's a confusion of terms, and they actually mean a pointer that points to only one object, rather than an array of objects.
0
 
Murugesan NagarajanSubject-matter expert at C++ C delivery, implementation, at UNIX oriented operating systems (Windows: CYGWIN_NT MINGW32_NT MINGW64_NT)Commented:
First, C is not suitable for OO programming. You'd be fighting all the way if you do. Secondly, singletons are just static variables with some encapsulation. So you can use a static global variable. However, global variables typically have far too many ills associated with them. You could otherwise use a function local static variable:

From the url:
[ur]
http://stackoverflow.com/questions/803673/how-to-create-a-singleton-in-c
[/ur]
0
 
Infinity08Commented:
>> First, C is not suitable for OO programming.

Even though I don't see how this is relevant to the question, I beg to differ. OO concepts have been used for professional C programming long before C++ existed. Sure, C++ added some syntactic conveniences etc., but the heart of OO can easily be followed in C (and it might even be a good idea to do so).


Anyway :

>> Secondly, singletons are just static variables with some encapsulation.

Scope or lifetime are not (directly) relevant to the concept of a singleton. Or in other words : a singleton doesn't need to be static.
The static keyword is often used to enforce certain aspects of a singleton implementation (specifically the one instance guarantee), but it is not required.


A singleton is simply a restriction that is placed on a type to have only one instance of it.

A "singleton pointer" is a less common term, so in order to be sure, I'd have to see the concept in which it is used. But I'd guess that it refers to a specific pointer type that should only have one instance. It's an odd idea, but maybe it makes sense in the specific case where it was used.
0
Worried about phishing attacks?

90% of attacks start with a phish. It’s critical that IT admins and MSSPs have the right security in place to protect their end users from these phishing attacks. Check out our latest feature brief for tips and tricks to keep your employees off a hackers line!

 
tittuAuthor Commented:
array vs singleton pointer in coverity testing described in C please eloborate this
I knew single pointers and array issues an eloborated explanation is required..
0
 
Infinity08Commented:
>> Not expected answers

It would have been nice if you could have said this earlier, instead of waiting 6 months.
It would also have been nice to tell us what you DID expect then, so we could adapt our answers.

As it stands now, a C grade is not acceptable. Either we didn't answer your question, and then you can give us an explanation of how we didn't answer your question, after which we can assist you further. Or we did answer your question, and then a grade higher than C seems appropriate.
0
 
Infinity08Commented:
>> instead of waiting 6 months.

I meant to say almost one month.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.