Virtual Destructor: For ex class Base { public: int a; }; class Derived:Base { }; int main() { Base * b=new Derived() delete b; } flow of constructor first create Base class Constructor 1.construct base class Constructor 2.construct Derived class Constructor 3.Delete Base Class Destructor Here Derived class Destructor is not call ,for it we need to declare Base class Destructor as a virtual Destructor class Base { public: Base(); ~virtual Base(); }; vTable:- It is a look up table for functions used to resolve at run time /dynamic .Every class that uses virtual function has its own virtual table (is it derived class or base class) .this table is simply a static array.that the compiler set at compiile time.
class Base { private: int priA; public: int pubA; protected: int protA }; class Derived: private Base /// it is Dertived has-a Base { public: }; this means its make all public member and protected member of Base class become private in derived class .so they can not visible outside of the derived class.thats the basic difference. class base { private : int PriA; public: int pubA; protected: int proA; }; class Derived: Protected { } pubic and protecated member...
Defination:-Copy Constructor creating a new object from existing object of same .When we do not define a copy constructor .compile provide a default copy constructor.when there is a object owns a pointer variable and a reference non shareable.Use of const Keyword becos e The const is there to ensure that you don't modify the other object. Signature of copy Constructor MyClass { Public: MyClass() { } MyClass(const MyClass&) { } }; or another ex X ( const X & copy_from_me ) ; X ( X & copy_from_me ) ; X ( const volatile X & copy_from_me ) ; X ( volatile X & copy_from_me ) ; X ( const X & copy_from_me, int = 10 ) ; X ( const X & copy_from_me, double = 1.0 , int = 40 ) ;
Model Dialog:- u have to respond them before processing further. Suppose a Dialog Class CMyDlg; CMyDlg myDlg; myDlg.DoModel() DoModel is use for Mode dialog Modelesss Dialog:-These stay on the screen u can respond them any time ,they donot stop u for further process. CreateDialog Method is use for Modeless Dialog. how to convert Model dialog in Modelless dialog. Model Dialog in place of DoModel() use Create() and showWindow () method create but Object of Dialog class should not be local else it will b crush after moving out of scope.
auto_ptr< int > p1 ( new int ); its a template .Which provides the limited garbage storage for the pointer .its destroy the pointer when auto ptr destroy.Since auto_ptr takes the repsonsibilty of pointer which it points.it solve the problem of dangling pointer.
Declaring a function with the key word const ,it is specifies that the function is Read Only method,that dones not modify that object for which it is called. Class Date { int month; public: Date (int month,int date,int year); int getMonth(int month); int setMonth(int month) const;//const method }; int Date::setMonth(int mon) { month=mon; } int main() { Date currentDate(1,1,2011); const Date birthDate(21,1,1987); currentDate.setMonth(...
First in your editor i am using vim filename.make this will open a make file now exec: ./file compile: / fileName.cpp g++ fileName.cpp -o file echo "compilation " touch compile and press esc key and :wq and for execution make file use make -f filename.make if in the last no comment after the file name then it will by default called the binary file make -f filename.make compile or if we pass "compile" then first its check that if filename.cpp timespan is less then the touch command compile timespan then it will again compile else it will not compile. and some another things we need to care that after compile: and / there should be a space and filename.cpp also in the same starting point as the compile: ...