Click here to Skip to main content
15,498,622 members

Manish K. Agarwal - Professional Profile


LinkedIn      Blog RSS
Working with Oracle. Using C/C++, VC++, MFC, STL, C#, Java etc. on various platform like Windows, Unix, Macintosh etc. from last 13+ years to convert various type of requirements into running software components. My core expertise is multithreaded desktop product and large scale enterprises software development.


Below is the list of groups in which the member is participating

Publisher CodeProject
Canada Canada
The CodeProject Advisors group is comprised of CodeProject members specifically chosen to advise the CodeProject on new products related to helping the community answer technical questions. This group participates in beta testing and feedback of products designed to help connect members with experts.
This is a Collaborative Group
This member has Member status in this group

28 members


Weekly Data. Recent events may not appear immediately. For information on Reputation please see the FAQ.


Members need to achieve at least one of the given member levels in the given reputation categories in order to perform a given action. For example, to store personal files in your account area you will need to achieve Platinum level in either the Author or Authority category. The "If Owner" column means that owners of an item automatically have the privilege. The member types column lists member types who gain the privilege regardless of their reputation level.

ActionAuthorAuthorityDebatorEditorEnquirerOrganiserParticipantIf OwnerMember Types
Have no restrictions on voting frequencysilversilversilversilver
Bypass spam checks when posting contentsilversilversilversilversilversilvergoldSubEditor, Mentor, Protector, Editor
Store personal files in your account areaplatinumplatinumSubEditor, Editor
Have live hyperlinks in your profilebronzebronzebronzebronzebronzebronzesilverSubEditor, Protector, Editor
Have the ability to include a biography in your profilebronzebronzebronzebronzebronzebronzesilverSubEditor, Protector, Editor
Edit a Question in Q&AsilversilversilversilverYesSubEditor, Protector, Editor
Edit an Answer in Q&AsilversilversilversilverYesSubEditor, Protector, Editor
Delete a Question in Q&AYesSubEditor, Protector, Editor
Delete an Answer in Q&AYesSubEditor, Protector, Editor
Report an ArticlesilversilversilversilverSubEditor, Mentor, Protector, Editor
Approve/Disapprove a pending ArticlegoldgoldgoldgoldSubEditor, Mentor, Protector, Editor
Edit other members' articlesSubEditor, Protector, Editor
Create an article without requiring moderationplatinumSubEditor, Mentor, Protector, Editor
Approve/Disapprove a pending QuestionProtector
Approve/Disapprove a pending AnswerProtector
Report a forum messagesilversilverbronzeProtector, Editor
Approve/Disapprove a pending Forum MessageProtector
Have the ability to send direct emails to members in the forumsProtector
Create a new tagsilversilversilversilver
Modify a tagsilversilversilversilver

Actions with a green tick can be performed by this member.

GeneralSQL date Format expression Pin
Manish K. Agarwal17-Feb-14 3:26
MemberManish K. Agarwal17-Feb-14 3:26 
GeneralJava RegEx to Normalize OS File Separator Char Pin
Manish K. Agarwal17-Feb-14 3:14
MemberManish K. Agarwal17-Feb-14 3:14 
Generallocale setting Pin
Manish K. Agarwal3-Nov-10 21:53
MemberManish K. Agarwal3-Nov-10 21:53 
GeneralWildcard pattern matching Pin
Manish K. Agarwal8-Jul-10 23:05
MemberManish K. Agarwal8-Jul-10 23:05 
GeneralRemote Debugging: Quick Steps Pin
Manish K. Agarwal19-Jun-09 2:07
MemberManish K. Agarwal19-Jun-09 2:07 
GeneralRe: Remote Debugging: Quick Steps Pin
TejaSingh8-Jul-09 21:05
MemberTejaSingh8-Jul-09 21:05 
GeneralAnother C++ Singleton pattern implementation Pin
Manish K. Agarwal7-Apr-09 20:21
MemberManish K. Agarwal7-Apr-09 20:21 
Generally I have seen that for singleton implementation, we declare a static pointer mSingletonP and static method GetInstance(). Inside GetInstance(), we check if mSingletonP is NULL, allocate it using new and return the pointer otherwise if it is already allocated simply return the pointer. Typically we implement like this:

class MySingleton
	static MySingleton *GetInstance(){
		if (mMySingletonP == NULL) {
			mMySingletonP = new MySingleton;

		return mMySingletonP;


	MySingleton(const MySingleton & ){

	MySingleton & operator=(const MySingleton & ) {
		// Wrong but we just want a private implementation
		// We simply want no one call this.
		return *((MySingleton *)NULL);


	static MySingleton *mMySingletonP;


Further if we want that at the end destructor must invoke, we use atexit(), C Run Time library function and register some function which will take care of delete mMySingltonP.

Recently I have a seen a nice implementation of Singleton. This implementation is good if want to invoke destructor without using atexit. This is not thread safe and this is based on a static keyword. Implementation is as below:

class Singleton
	static Singleton &GetInstance(){
		static Singleton instance;

		return instance;


	Singleton(const Singleton & ){

	Singleton & operator=(const Singleton & ) {
		// We simply want no one call this.
		return *this;



Above is the best implementation for non thread safe singleton and below is the best implementation for thread safe singleton.

For thread safe implementation of GetInstance() we use double NULL checking and locking in our traditional singleton implementation i.e.

static MySingleton *GetInstance() {

     if (mMySingletonP == NULL) {
           // Aquire a lock here
           if (mMySingletonP == NULL) {
                mMySingletonP = new MySingleton;
           // relase lock here

     return mMySingletonP;

Please share your views on the same.

int _tmain(int argc, _TCHAR* argv[])
	int nTmp1 = 10;
	Singleton &firstRef = Singleton::GetInstance();

	Singleton &otherRef = Singleton::GetInstance();

	return 0;

Manish Agarwal
manish.k.agarwal @ gmail DOT com

Generalsprintf_s on UNIX / Mac Pin
Manish K. Agarwal21-Nov-08 0:42
MemberManish K. Agarwal21-Nov-08 0:42 
GeneralActivation Codes Pin
Manish K. Agarwal24-Nov-05 19:55
MemberManish K. Agarwal24-Nov-05 19:55 

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.