Skip to main content

Posts

Showing posts from September, 2011

3 d Array example

#include <stdio.h> #include <stdlib.h> int main() { int ***a=0; a=new int**[1]; for(int i=0;i<1;i++) { a[i]=new int*[2]; } for(int i=0;i<1;i++) { for(int j=0;j<2;j++) { a[i][j]=new int[3]; } } printf("enter the value of a[i][j][k] = ") ; for(int i=0;i<1;i++) { for(int j=0;j<2;j++) { for(int k=0;k<3;k++) { scanf("%d",&a[i][j][k]); } printf("\n") ; } } printf(" value of a[i][j][k] \n"); for(int i=0;i<1;i++) { for(int j=0;j<2;j++) { for(int k=0;k<3;k++) { printf("\t %d",a[i][j][k]) ; } printf("\n") ; } } for(int i=0;i<1;i++) { for(int j=0;j<2;j++) { delete []a; } } return 1; }

2d pointer array

#include <iostream> using namespace std; void main() { int i=0; int **array; a=new int*[ROW]; for(int i=0;i<ROW;i++) {    a[i]=new int [COLUMN]; } for( i=0;i<1;i++) { for(int j=0;j<3;j++) { cout<<"enter the value of a[i][j] = " ; cin>>a[i][j]; } } cout<< "value of a[i][j] \n"; for( i=0;i<1;i++) { for(int j=0;j<3;j++) { cin>>a[i][j] ; } } for( i=0;i<1;i++) { delete []a[i]; delete []a; } }

what is vector and implemantation

Vector are sequence container.vector containers are implemented as dynamic array.vector store elements in  contiguous  memory allocation.means vector elements we can find using pointer. features of vector 1.Access elements in according to index value. 2.iterate element in any order in liner time 3.Remove element from its end (constant time) they are same like a array but in vector memory handle in dynamic way

Convert CStrng to Ctime and again format in CString

using this i converted my CString 12 hr format time into 24 hr format time in vc++ CString strDateTime="2005/09/12 11:10:12 PM"; COleDateTime myDateTime; CTime conTime; if(myDateTime.ParseDateTime(strDateTime,0)) {                SYSTEMTIME st;                 if (myDateTime.GetAsSystemTime(st))                    {                              sysTime =st;                    }                 } strDateTime=sysTime.Format("%Y-%m-%d %H:%M:%S");

Link Error LNK2001: Unresolved External Symbol _mainthread

To avoid these unresolved external errors, do not set the Project Settings to Single-Threaded for an MFC version 3.0 or later application. This setting can be changed by doing the following: On Microsoft Visual C++ .NET 2003 Click the  Project  menu. Click  <project_name>  Properties . Expand  Configuration Properties , and then click  C/C++ . Click  Code Generation . In the right pane, make a selection other than  Single-threaded  or  Single-threaded Debug  in the  Runtime Library  list. On Microsoft Visual C ++ 2. x , 5.0, and 6.0 Select the  Project  menu. Select the  Settings...  option. Select the  C/C++  tab. Select  Code Generation  on the  Category  list box. Finally, make a selection other than  Single-Threaded  on the  Use Run Time Library  list box. On Microsoft Visual C++ 4. x Select the  Build  menu. Sele...

Singleton class

A class whose number of instance that can be  instantiated  is limited to one is called a Singleton class.that means at any given time only one instance exist. Class Singleton {       private:              static bool bFlag;              static Singleton *Single;                 Singleton()               {               }      public:            static Singleton * getInstance();            void method();             ~Singelton()                {                      bflag=false;                  } }; bool Singleton: : Si...

Mutex with Singleton Class

in this post used Mutex for Syncronization there create three class Lock,Mutex and Singleton class // multiThreading.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include "Windows.h" #include "process.h" #include "iostream" using namespace std; class Mutex { public: Mutex() { InitializeCriticalSection(& _CritSection); } ~Mutex() { DeleteCriticalSection(& _CritSection); } private: friend class Lock; CRITICAL_SECTION _CritSection; BOOL mutexAcquire; void Acquire() { EnterCriticalSection(& _CritSection); } void Release() { LeaveCriticalSection(& _CritSection); } }; class Lock { public: Lock ( Mutex & mutex ) : _mutex(mutex)     {         _mutex.Acquire();     }     // Release the state of the semaphore     ~Lock ()     {         _mutex.Release();     ...

Mutex using singlton class

in this post used Mutex for Syncronization there create three class Lock,Mutex and Singleton class // multiThreading.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include "Windows.h" #include "process.h" #include "iostream" using namespace std; class Mutex { public: Mutex() { InitializeCriticalSection(& _CritSection); } ~Mutex() { DeleteCriticalSection(& _CritSection); } private: friend class Lock; CRITICAL_SECTION _CritSection; BOOL mutexAcquire; void Acquire() { EnterCriticalSection(& _CritSection); } void Release() { LeaveCriticalSection(& _CritSection); } }; class Lock { public: Lock ( Mutex & mutex ) : _mutex(mutex)     {         _mutex.Acquire();     }     // Release the state of the semaphore     ~Lock ()     {         _mutex.Release();     ...

What is COM and What is its Base interface

First What is COM? COM stands for Component object model.it is used to enable a inter process communication,dynamically can create object in large range of programming language. All COM Component must implemet the  standard IUnknown ,thus all com interface  derived from IUnknown..it contain three methods AddRef(),Release() which are use for counting the reference counting,last one is QueryInterface() which control the life time of interface. CoCreateInstance()  API can be used by an application to directly create a COM object without acquiring the object's class factory. or CreateObject() also use for creating an object IMoniker :- it used to uniquely identify the COM Object,as a same way as a path identifier find the path ,IMoniker identify the COM Object in the directory Namespace.