Difference between Constructors and static constructors?
Answers were Sorted based on User's Feedback
Answer / nayer plame
In C++ the difference is: static constructor do not exist in
C++ and constructors do exist
Is This Answer Correct ? | 7 Yes | 1 No |
Answer / venkataramakrishna. danduri
The main thing is the constructoe can't be Static, int or
any other data type. It will simpley throws a error
messgae. It is just to confuse the candidate.
Example:
class A
{
public:
static A(){ a = 0;}
int a;
};
void main()
{
A a;
}
Is This Answer Correct ? | 2 Yes | 0 No |
Answer / ganagdhara c
the normal constructor is use to initialize the data elements of the objects which are either static are non static elements where as thee static constructors are use to initialize the static data elements in the class these static data elements are shared by all the objects of the class type these are created when the first object of the class type was created.
Is This Answer Correct ? | 1 Yes | 1 No |
Are there any new intrinsic (built-in) data types?
What is pure virtual function?
Is there any difference between int [] a and int a [] in c++?
What is the need of a destructor?
In a function declaration what does extern means?
Can comments be nested?
Write a String class which has: 1) default constructor 2) copy constructor 3) destructor 4) equality operator similar to strcmp 5) constructor which takes a character array parameter 6) stream << operator
2 Answers HCL, Lehman Brothers, Zoomerang,
Which one between if-else and switch is more efficient?
A company pays its salespeople on a commission basis. The salespeople receive $200 per week plus 9 percent of their gross sales for that week. For example, a saleperson who sells $5000 worth of merchandise in a week receives $200 plus 9 percent of $5000, or a total of $650. You have been supplied with a list of items sold by each salesperson. The values of these items are as follows: Item Value A 239.99 B 129.75 C 99.95 D 350.89 Write a program that inputs one salesperson's items sold in a week (how many of item A? of item B? etc.) and calculates and displays that salesperson's earnings for that week.
What is the two main roles of operating system?
What is encapsulation in c++?
Difference between const char* p and char const* p?