you can instantiat a template in two ways. 1. Implicit instantiation and 2. Explicit Instantion. implicit instatanitioan can be done by the following ways:template <class T>class A{public: A(){}...
Pass By Value example:The function receives a copy of the variable. This local copy has scope, that is, exists only within the function. Any changes to the variable made in the function are not passed...
rahultripathi
Sep 24th, 2005
There is major defference between these three are when we want to avoid making the copy of variable and we want to change value of actual argument on calling function. there are we use passing by pointer,passing the reference. We can not perform arithmentic operation on reference.
In case of Array , the ArrayName is Nothing but a Base Address, when we use [] operator , it treats leftmostvalue as a base address and rightside value as an offset so it adds BaseAddress+Offset and g...
paulson paul chambakottukudyil
Apr 12th, 2006
Array name is a constant pointer pointing to the base address(address of the first byte where the array begin) of the memory allocated. When you use arr[i], the compiler manipulates it as *(arr + i). ...
Run-time type information (RTTI) is a mechanism that allows the type of an object to be determined during program execution. RTTI was added to the C++ language because many vendors of class libraries ...
A
Jan 28th, 2006
In case of Virtual function we are responsible for deciding the function at run time. Its our logic that reflects and no one does any thing.Where as in case of RTTI TYPE is found of object. We dont do any thing for that. We simply use that.
Constructor is initialized the data members....in the above case no data members r there in the class.....so....i think compiler call default constructor but it does nothing...
When a c++ program is compiled and executed the constructor is invoked first. if a constructor is not declared or defined by the user then the compiler invokes the default constructor.
To avoid memmory leaks you should use smart pointers.
Guest
Jul 17th, 2006
When dynamic memory allocation is used extensively, memory leak may occur.It happens when first memory block is not deleted . However, the address is lost because the pointer contains the address of s...
In general, volatile keyword signals compiler that the declared variable should not be optimized by any ways (e.g. it should not be cached, kept in registers etc but anytime it's used - it should be r...
minli
Apr 9th, 2006
(P876 from textbook C++ How To Program:)The volatile type qualifier is applied to a definition of a variable that may be altered from outside the program (i.e., the variable is not completely under th...
The code mentioned would give errors while compiling. But when i have done some minor modifications to successfully compile the code, I was surprised to c that this code works fine.Later i had to come...
jayq
Sep 17th, 2006
The program you supplied has many type'o's so it will output only compile time errors.However if you fix the syntax, there'll be no controversy in this source : it ALWAYS outputs : its in main program...
You CAN in SOME compilers, but it should be noted that according to Stroustrup onlyint main()and its argc,argv cousins are valid declarations of main according to the standard.
Akif
May 3rd, 2006
hiiiiiiiiiiiiiiiits possible u make ur main function int float char its depend what u return if u return char then ur main function char main()
I believe that you may be able to override main (I haven't actually tried though..). I don't see why you'd get any linker errors if you re-def the entry point as a linker switch...Thoughts?Anybody have time to try? =D
a 3-d array is collection 2-d arrays as rows.ex: a[2][3][4] means 'a' contains two 2-d arrays of each size [3][4].first subscript 2 indicates that 'a' contains two arrays which have 3-rows and 4-coloumns.
hanuman
Nov 13th, 2006
let us take an example main(){int a[2][2][2];int i,j,k;for(i=0;i<2;i++) for(j=0;j<2;j++) for(k=0;k<2;k++) &n...
Enum is not an operator. It is a datatype. Hence it can NOT be overloaded as an operator.You can define operations on enum datatypes and Overload operators for perfoming operations using enum though.I...
A static array is an array with fixed number of dimentions and each dimention will have fixed length. You can not change the dimentions of the Static array during runtime.ex: int arr[10][20] It has Tw...
Well, the static variable should not be accessed from outside the file in hich it is defined. That's how static is defined.The intended purpose of static is to make the variable "invisible" to other programs.Hence you must use extern if you want to access it across files.Cheers,Kalayama
Arun
Nov 30th, 2006
Hi, We can't able to use more than one storage class specifier in same variable.Regards,ARUN
depends on the requirement. if you got fixed no of arguments like,sum(int, int)sum(float, float) .. go for Templates.If you have variable arguments and you know the data types, then make use of va_lis...
satyam
Dec 18th, 2006
To some extent this can be achieved by using default arguments for the func. But this also depends what all parameters you need to pass in different cases.
Ans