473,783 Members | 2,475 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Doubts regarding constructor

6 New Member
Hi

I have a two doubt's regarding constructor. Consider the following situation.

I have two classes A & B. A is the base class and B is a class which inherits class A. I have main function in class B and I create an object for class B. So, first the class A constructor gets executed (since it is the base class) and then the class B constructor gets executed.

1) When I use parameters in both the constructor I am forced to use base keyword in derived class. Why is that so?.

2) When the derived class takes parameters and the base class doesn't take any parameter and if I create an object for derived class, how can I work on it?.

Thanks,
Sanjay
Dec 24 '07 #1
1 1005
shweta123
692 Recognized Expert Contributor
Hi,

Please refer this

Article for your doubts regarding constructors.
Dec 26 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
1582
by: ritesh | last post by:
Hi, I have been reading some text on C and C++ (i.e advanced books). One of the books mentioned that C++ requires a runtime support whereas C does not - what the author was trying to say was that once you compile a C program the executable created is all that is needed whereas if you compile a C++ program the executable created requires a C++ runtime installed on your system to run the program. Can someone please provide more...
2
1306
by: VMI | last post by:
I'm having doubts as to how the compiler interprets this If statement: bool bIsTrue = true; if (! bIsTrue) { //RUN PROCESS } Here, will "RUN PROCESS" be executed? Or is this just wrong? How is this
3
1919
by: Karl M | last post by:
Hi everyone, I just notice some strange behaviors on the MS C++ compiler regarding struct default constructor, see the example bellow: struct MyStruct { int a; }; class MyClass { public:
1
1391
by: archana | last post by:
Hi all, I want to clear one doubt which i am facing regarding timer. Suppose i have one timer in which i am generating some files. and interval of my timer is say 5 min. Say suppose at then my files are generated at time 12:30 am and then as i set interval to 5 next file should gets generated to 12:35 but what if i change my system time to 12:25 or 12:34.
17
2334
by: Ashwin | last post by:
hi guys, i have overloaded the << operator.as shown below. ostream& operator<<(ostream &out, const student &a) { out<<a.idno; out<< " " ; // out<< a.name; out<< " " ; // out<< a.marks << endl;
1
1664
by: 418928 | last post by:
Hi everybody, I have some doubts about RDF. I hope you can help me with them: -In http://www.w3.org/TR/rdf-primer, they use the namespace "http://www.example.org/terms/">", but the URL "http:// www.example.org" does not exist, so it doesn't define any terms. Is this out-of-date? -Difference between rdf:about and rdf:ID. Can I use only rdf:about?
1
1787
by: ramasubramanian.rahul | last post by:
hi people.. dont know if this the right forum for this doubt ... so sorry if i am mis-posting... i was looking at the way glib 2.10.3 does export optimization using a list of "to be exposed" function names in a file caleed glib.symbols. this file is used by a perl script to generate a header a .c file ( galias.h and galiasdefs.c). This files essentially enusres default visibility for these functions (using the __attribute__((default))__...
6
1452
by: alessio211734 | last post by:
I have a class that defines a generic point where p={a1..an} template<class T,int iclass Point { public: T v; Point<T,i>() { for (int j=0;j<i;j++) v=0;
4
2064
by: Pranav | last post by:
Hello All, I have a simple question regarding the definition of abstract class, IIRC , Abstract class is one which contains virtual function declaration and other variables and no object of this class is created directly. If this is the case why don't we hide the constructor of abstract class into protected region? So that only object which inherits it can call the ctor of abstract class. In this way no one can create the object of...
0
9643
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10315
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10083
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8968
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7494
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5379
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4044
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2877
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.