473,399 Members | 2,146 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

How can we refer superclass constructor from subclass in c++ ???

1..In java we can refer superclass constructor by super()keyword,but
Where as in c++ how can we refer to that???.

In java the following code is used for referring superclass constructor..
Expand|Select|Wrap|Line Numbers
  1. class cal1
  2.     {
  3.       private int a,b,c;
  4.       public cal1(int i,int j)
  5.       {
  6.       a=i;
  7.       b=j;
  8.      }
  9.      public void add()
  10.      {
  11.       c=a+b;
  12.       System.out.println("addition is "+c);
  13.      }
  14.    }
  15. class cal2 extends cal1
  16. {
  17.   private int a1,b1,c1;
  18.   public cal2(int i1,int j1,int k1,int l1)
  19.   {
  20.    super(i1,j1);
  21.    a1=k1;
  22.    b1=l1;
  23.   }
  24.   public void mul()
  25.   {
  26.    c1=a1*b1;
  27.    System.out.println("mul is "+c1); 
  28.   }
  29. }
Mar 20 '07 #1
1 2848
dmjpro
2,476 2GB
try this .....

Expand|Select|Wrap|Line Numbers
  1. class A
  2. {
  3. public:
  4.     A(int i){}
  5. };
  6.  
  7. class B : public A
  8. {
  9. public:
  10.     B(int i):A(i)
  11.     {}
  12. }
  13.  
welcome again
Mar 20 '07 #2

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

Similar topics

2
by: Reid Priedhorsky | last post by:
Dear group, I'd have a class defined in one module, which descends from another class defined in a different module. I'd like the superclass to be able to access objects defined in the first...
2
by: stephane | last post by:
Hi all, What I am trying to achieve is an 'inherits' method similar to Douglas Crockford's (http://www.crockford.com/javascript/inheritance.html) but that can enable access to the superclass'...
4
by: ingoweiss | last post by:
Hi, I am having trouble passing parameters of a Javascript subclass constructor through to it's superclass constructor. I am trying all sorts of things, including the below, but nothing...
0
by: Queen | last post by:
Hi! First of all, perdon for my English. I don't express the thinks very good. Well, I'm working with eclipse 3.1.1, wxWidgets 2.4.2, MSYS 1.0.10 and Mingw 3.1.0. I'm doing a project in c++....
6
by: bill226 | last post by:
I have to get the subclass to use the superclass constructor, heres my code: public class Student { // instance variables private String name; private int pin; private...
14
by: Marko | last post by:
I have abstract superclass named Element, and several subclasses derived from it: And, Or, Nand, Nor... I have method which has to take 2 subclasses of element as its parameters types. Can't use ...
2
by: Mark Brading | last post by:
Hi all, I am trying to declare a Map object with an abstract superclass (TableFields_v2) object as follows:- private Map<Integer, TableFields_v2> elementList; When I come to create the object...
6
by: Author | last post by:
I have class BaseClass { public BaseClass(string s1, string s2) { this.S1 = s1; this.S2 = s2; } public string S1 { get; set;}
1
by: jimismint | last post by:
Hi guys, i'm stuck on this problem. only just recently started coding java using blue J. Can you guys help me. import java.util.*;...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...
0
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...

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.