Forums.Sureshkumar.net : A Perfect Place to Share Knowledge         Blogs     Games    Magazines    

"Sharing knowledge does not lessen your store, often it gets you more. Sharing plays a key role in relationships and bonding, happens in small steps and is assisted through community membership."

Go Back   SURESHKUMAR.NET FORUMS > TECHNICAL DISCUSSIONS > DATA STRUCTURES, C, C++, VC ++ > ds. c , c++ Interview / Technical Questions
Register FAQ Members List Calendar Games Blogs Search Today's Posts Mark Forums Read

ds. c , c++ Interview / Technical Questions Kindly solve an many as questions you can. It will sharpen your skills and those solutions will help others too.

   

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
Old 29-11-07, 01:21 PM   #1 (permalink)
Junior Member
 
Join Date: Sep 2007
Age: 25
Posts: 16
Thanks: 1
Thanked 0 Times in 0 Posts
Thanks: 1
Thanked 0 Times in 0 Posts
Rep Power: 2 gouriproutray is on a distinguished road
Smile How to access the base constructor???

#include<stdio.h>
#include<conio.h>
#include<iostream.h>
class sample
{
sample()//sample constructor declared in private part
{
a=10;
}
int a;
static sample*pp;
public:
static sample* create()
{
pp=new sample;//creating sample class object
return pp;
}
void show()
{
cout<<a;
}
};
class derived:public sample
{
int x;
public:
derived() //derived constructor declared in public part
{ //how to access the base class' "sample" constructor
x=20; //here...the error is present here..cannot access
} // base class constructor
};
sample* sample::pp;
void main()
{
derived obj1;//creating derived object
getch();
}
/* my question is ..this program will not compile because we cannot access the base class' (here is sample) constructor because it is declared in private part in base..then HOW CAN WE CRATE AN OBJECT OF DERIVED CLASS..i tried a lot but cannot find the solution..actually this is possible or not..do not try this program to run in turbo or vc++ compiler.because you cannot create private constructor in these..but private constructor is possible in unix,linux c,c++*/
gouriproutray is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 30-11-07, 12:34 PM   #2 (permalink)
Junior Member
 
Join Date: Aug 2007
Age: 25
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 2 sajishk@gmail.com is on a distinguished road
Re: How to access the base constructor???

This is really a gud Question and I believe u only has given the (Hidden)answer wid it.
Because thats the speciality of Obj-Oriented programming, there will enough security and there will not be any free-flow of data unless the programmer desires it...Hence the inclusion of Access Specifiers (Private, Public, Protected).
While these features are not involved in unix, linux....

Do correct me if I am wrong...
sajishk@gmail.com is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 30-11-07, 12:53 PM   #3 (permalink)
Junior Member
 
Join Date: Sep 2007
Age: 25
Posts: 16
Thanks: 1
Thanked 0 Times in 0 Posts
Thanks: 1
Thanked 0 Times in 0 Posts
Rep Power: 2 gouriproutray is on a distinguished road
Re: How to access the base constructor???

dear sajishk

in most of the software companies they are using unix or linux. how can u say these features(private,public,protected) are not involved . all r available with unix,linux.
gouriproutray is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 02-12-07, 08:10 AM   #4 (permalink)
Junior Member
 
Join Date: Aug 2007
Age: 25
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 2 sajishk@gmail.com is on a distinguished road
Re: How to access the base constructor???

Gouriproutray,
Oh!! reallly so.....If that is the case then I must thnk you to pass this piece of info into me ....
sajishk@gmail.com is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Mega Free Download S/W Links A-Z yathish OTHERS 513 30-09-08 02:49 PM
Bob Technologies placement paper 2 sridhar BOB TECHNOLOGIES Placement Papers 0 03-02-07 07:43 PM
Bob Technologies placement paper 1 sridhar BOB TECHNOLOGIES Placement Papers 0 03-02-07 07:42 PM
Calls to India and other International destinations just got even cheaper!!! AjayKumar.Kataram Amazing TIPS & TRICKS 2 09-12-06 03:40 PM
JAVA collection naga JAVA Technologies 0 21-02-06 06:01 AM


All times are GMT +6.5. The time now is 12:43 PM.





Search Engine Optimization by vBSEO 3.1.0