Paras Fadte wrote:
> Hi,
>
> Is it necessary to have a zero argument constructor If there is a
> one/two/three etc argument constructor in C++ ?
Not required by C++, but the code and usage may make one necessary.
You can have as many constructor parameters as you need from 0 up. And
as many different constructors as you need to do different jobs.
The only 'rule' we have in squid is that if you do have a 'default'
constructor (ie one with no parameters) you must also have a proper
destructor and assignment operator: operator=(...)
> Also, what is the
> significance of using size_t instead of a "int" data type ?
size_t is named to describe its use. It's unsigned to record the length
of things.
IIRC there is a different contextual meaning in squid. Hopefully one of
the others can tell us both what.
Amos
>
> Thank you.
>
> -Paras
>
> On Fri, Apr 18, 2008 at 9:25 AM, Amos Jeffries <squid3@treenet.co.nz> wrote:
>> Henrik Nordstrom wrote:
>>
>>> Tor 2008-04-17 klockan 21:19 +0530 skrev Paras Fadte:
>>>
>>>
>>>> With respect to C++ , is a static member of a class like a global
>>>> variable?
>>>>
>>> Yes, a class scoped (not object) global variable.
>>>
>>>
>>>> Does OOP in particular consider use of a static/global
>>>> variable as a bad programming practice?
>>>>
>>> Most do..
>>>
>>> But it do make life a lot easier..
>>>
>>
>> Which for leads to a few well-known problems, and the reasons why its often
>> considered bad. I'm not hypocritical to outlaw it, but advise Programming
>> carefully if you think you need any.
>>
>>
>> I judge it based on the objects design.
>> - 'manager' type class with only one instance static/global can be useful,
>> simpler, and faster. Especially to guarantee the rule that there is only
>> one. Go ahead consider it.
>> - minor object likely to have several usages or re-usage, static becomes a
>> major headache.
>> - static variable in functions called recursively, MAJOR headache.
>>
>>
>> globals, I don't think are as evil as made out to be. Often a little
>> thought can lead you to conclude a direct need for being global. Or to a way
>> of cleanly scoping them somewhere so it does not matter.
>>
>> My cleanup side-project is going through the main squid headers testing all
>> the usages these days.
>>
>>
>>
>> Amos
>> --
>> Please use Squid 2.6.STABLE19 or 3.0.STABLE4
>>
-- Please use Squid 2.6.STABLE19 or 3.0.STABLE4Received on Wed Apr 30 2008 - 11:51:32 MDT
This archive was generated by hypermail 2.2.0 : Wed Apr 30 2008 - 12:00:07 MDT