freelanceprogrammers.org Forum Index » C

C++ Doubt


View user's profile Post To page top
shabbir_saiyed@... Posted: Thu Jul 10, 2003 5:00 pm


Joined: 10 Jul 2003

Posts: 4
C++ Doubt
Hi friends ,
I`m new member to this group . i`m a beginner .
i have some doubt.

why construtor can not be virtual ????
why static member function can not be const ?????

Plz don`t laugh if doubt is stupid :(

-Shabbir (Babblu B. Com. ,MBA)




___________________________________________________
Click below to experience Sooraj R Barjatya`s latest offering
`Main Prem Ki Diwani Hoon` starring Hrithik, Abhishek
& Kareena http://www.mpkdh.com
Reply with quote
Send private message
View user's profile Post To page top
sudhanshu_sa... Posted: Fri Jul 11, 2003 11:28 am


Joined: 11 Jul 2003

Posts: 2
C++ Doubt
Hi,
 
 virtual call  gets work done with partial information also.
virtual allows to call a function knowing only an interfaces
 and not the exact type of the object.
but to create an object you need complete information.
We need to know the exact type  what is to be created.
thus, a call to a constructor cannot be virtual.
 
Regards,
Sudhanshu

-----Original Message-----From: suman [mailto:mansu@...]Sent: Monday, July 14, 2003 1:43 AMTo: Programmers-Town@yahoogroups.comSubject: Re: [Programmers-Town] C++ DoubtOn Thu July 10 2003 17:30, Shabbir Ali Saiyed wrote:> Hi friends ,>             I`m new member to this group . i`m a beginner .>    i have some doubt.>>     why construtor can not be virtual ????>     why static member function can not be const ?????>>   Plz don`t laugh if doubt is stupid :(>hi static member function in c only acts on static data i.e it changes static data. and const is used when data desn`t change.so u have a contradiction here.when data doesn`t change why use a ststic function at all use a normal func.also the same is abt constructer.say the constructer is virtual.so if inherit tis class...what am i gonna do..........reimplement the constucter whch doesn`t make sense because the child class c`s constucter shud be c .so if the parent class is p then it`s constructer is p::p()so what am i gonna use p in class c it doesn`t work as a constructer.so a constructer can`t be a virtual func.also even if it was allowed the disadvantages are1.it`s not useful2.what am i gonno do with a func which creates object b and  it can`t be usd as a normal func. because it doesn`t have a reaturn type.HTH-sumanTo unsubscribe from this group, send an email to:Programmers-Town-unsubscribe@yahoogroups.comYour use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
Reply with quote
Send private message
View user's profile Post To page top
girish_johar... Posted: Fri Jul 11, 2003 11:13 pm


Joined: 11 Jul 2003

Posts: 1
C++ Doubt
hi Shabbir ,
   i worked in C++ for 2 years presently working in java . but the reasons are similar constructors can not be overridden so they should be not virtual see things are very logical are and realistic . Don`t go for language constraints and dont  cram them try to understand what problems they will be having if they are not applied while designing an  reallife application.
rgds
Girish Shabbir Ali Saiyed <shabbir_saiyed@...> wrote:
Hi friends ,            I`m new member to this group . i`m a beginner .   i have some doubt.    why construtor can not be virtual ????    why static member function can not be const ?????  Plz don`t laugh if doubt is stupid :(-Shabbir (Babblu B. Com. ,MBA)___________________________________________________Click below to experience Sooraj R Barjatya`s latest offering`Main Prem Ki Diwani Hoon` starring Hrithik, Abhishek  & Kareena http://www.mpkdh.comTo unsubscribe from this group, send an email to:Programmers-Town-unsubscribe@yahoogroups.comYour use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
Reply with quote
Send private message
View user's profile Post To page top
suman_karumuri Posted: Mon Jul 14, 2003 1:12 am


Joined: 08 Jul 2003

Posts: 6
C++ Doubt
On Thu July 10 2003 17:30, Shabbir Ali Saiyed wrote:
> Hi friends ,
> I`m new member to this group . i`m a beginner .
> i have some doubt.
>
> why construtor can not be virtual ????
> why static member function can not be const ?????
>
> Plz don`t laugh if doubt is stupid :(
>
hi
static member function in c only acts on static data i.e it changes static
data. and const is used when data desn`t change.
so u have a contradiction here.
when data doesn`t change why use a ststic function at all use a normal func.

also the same is abt constructer.say the constructer is virtual.so if inherit
tis class...what am i gonna do..........reimplement the constucter whch
doesn`t make sense because the child class c`s constucter shud be c .so if
the parent class is p then it`s constructer is p::p()
so what am i gonna use p in class c it doesn`t work as a constructer.
so a constructer can`t be a virtual func.
also even if it was allowed the disadvantages are
1.it`s not useful
2.what am i gonno do with a func which creates object b and it can`t be usd
as a normal func. because it doesn`t have a reaturn type.
HTH
-suman
Reply with quote
Send private message
Post new topic Reply to topic
Display posts from previous:   
 

All times are GMT
Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Freelace Website Designer - Customer web design and software building.
China Wholesale - Electronics Products
Character Studio - Tutorials and Help