473,394 Members | 1,802 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,394 software developers and data experts.

trouble with constructor

Expand|Select|Wrap|Line Numbers
  1. Public class class1
  2. {
  3. public class1(int i)
  4. {
  5.     messagebox.show(“parent class”);
  6. }
  7. }
  8.  
  9. public class class2:class1
  10. {
  11. public void xyz()
  12. {
  13. messagebox.show(“child class”);
  14. }
  15. }
  16.  
why error coming-no overload for method class1 takes 0 arguments

why not implicitly creating default const for base class
Expand|Select|Wrap|Line Numbers
  1. Public class class1
  2. {
  3. }
  4.  
  5. public class class2:class1
  6. {
  7. public void xyz()
  8. {
  9. messagebox.show(“child class”);
  10. }
  11. }
  12.  
no error??why?

help me out!!!!!
Apr 2 '08 #1
3 897
Plater
7,872 Expert 4TB
It tells you exactly what the problem is. You do not have a constructor that takes no arguments.
If you look at the constructors of class1 in your first example, you will see that there is no default constructor for the class, only a constructor that takes an int.
You would need to add the default (no arguments) constructor.
Apr 2 '08 #2
public class class1
{
public class1(int i)
{
messagebox.show("parent class");
}
}

o/p---parent class

here there is no need to explicitly define default constructor...

but in case below why it is need to define default constructor....


1. Public class class1
2. {
3. public class1(int i)
4. {
5. messagebox.show(“parent class”);
6. }
7. }
8.
9. public class class2:class1
10. {
11. public void xyz()
12. {
13. messagebox.show(“child class”);
14. }
15. }
Apr 2 '08 #3
Plater
7,872 Expert 4TB
A blank constructor is "assumed" when no other constructors are declared. As soon as you declare a constructor, the default constructor is no longer assumed.
Should not be hard.
Apr 2 '08 #4

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

Similar topics

4
by: Jacek Dziedzic | last post by:
Hi! First of all, I hope my problem is not too loosely tied to the "standard C++" that is the topic of this group. I have some code that exhibits a strange behaviour: on one computer, where I...
22
by: San | last post by:
Hi, I wrote two simple constructors (one of them default) to initialize a student object. Student::Student(string name) { student_name = name; student_id = LATEST_ID + 1;...
6
by: DJ | last post by:
I am currently having trouble with strings. I have a private string variable in my class and i assign a value to it in the creation function as follows. #include <string> using std::string; ...
8
by: Exits Funnel | last post by:
Hello, I've been tasked with porting some C++ code from Windows to Linux. The following excerpt is giving me trouble: //BEGIN CODE #include <string> class TempTestBase_t {
14
by: Gregory L. Hansen | last post by:
I can't seem to make a queue of objects, using the STL queue. I'm trying to make a little event manager, and I just want someplace to store events. The method definitions for EventManager have...
3
by: James | last post by:
I have a base class that has constructor Person(string name, int age) and a derived class Empolyee(string job_title, int salary) When I try to call it using new Employee(name, age, job_title,...
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...
2
by: bellerophon | last post by:
I am having a serious trouble with my pointers in a programm that uses dll and was hoping that somebody in this group could help me: I export my DLL classes with declspec(dllexport) and link...
9
by: itdevries | last post by:
Hi, I've ran into some trouble with an overloaded + operator, maybe someone can give me some hints what to look out for. I've got my own custom vector class, as a part of that I've overloaded...
5
matheussousuke
by: matheussousuke | last post by:
Hello, I'm using tiny MCE plugin on my oscommerce and it is inserting my website URL when I use insert image function in the emails. The goal is: Make it send the email with the URL...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
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
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...
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...

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.