473,587 Members | 2,487 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Erros: Overloaded constructor not found, EOF found

3 New Member
Hi,

I have got seven error and I dont find why compiler find error..

//commission class definition
#ifndef COMMISSION_H
#define COMMISSION_H

#include <string>
using std::string;

class Commission
{
public:
Commission(cons t string &,const string &,const string &,const string &,double=0.0,do uble=0.0);

void setFirstName(co nst string &);
string getFirstName() const;

void setLastName(con st string &);
string getLastName() const;

void setSocialSecuri tyNumber(const string &);
string getSocialSecuri tyNumber() const;

void setGrossSales(d ouble);
double getGrossSales() const;

void setCommissionRa te(double);
double getCommissionRa te() const;

double earnings() const;
void print() const;
private:
string firstName;
string lastName;
string socialSecurityN umber;
double grossRate;
double commmisionRate;
};

#endif

//base class definition
#ifndef BASE_H
#define BASE_H

#include <string>
using std::string;

#include "commission .h"

class Base
{
public:
Base(const string &,const string &,const string &,const string &,double=0.0,do uble=0.0,double =0.0);
void setBaseSalary(d ouble);
double getBaseSalary() const;

double earnings() const;
void print() const;
private:
double baseSalary;
};

#endif


//Commission class member function definitions
#include <iostream>
using std::cout;

#include "commission .h"

Commission::Com mission(const string &first,const string &last,const string &ssn,double sales,double rate)
:firstName(firs t),lastName(las t),socialSecuri tyNumber(ssn)
{
setGrossSales(s ales);
setCommissionRa te(rate);
}

void Commission::set FirstName(const string &first)
{
firstName = first;
}

string Commission::get FirstName() const
{
return firstName;
}

void Commission::set LastName(const string &last)
{
lastName = last;
}

string Commission::get LastName() const
{
return lastName;
}

void Commission::set SocialSecurityN umber(const string &ssn)
{
socialSecurityN umber = ssn;
}

string Commission::get SocialSecurityN umber() const
{
return socialSecurityN umber;
}

void Commission::set GrossSales(doub le sales)
{
grossSales = (sales<0.0 ? 0.0 : sales);
}

double Commission::get GrossSales() const
{
return grossSales;
}

void Commission::set CommissionRate( double rate)
{
grossRate = (rate>0.0 && rate<1.0) rate : 0.0;
}

double Commission::get CommissionRate( ) const
{
return grossRate;
}

double Commission::ear nings() const
{
return getCommissionRa te() * getGrossSales() ;
}

void Commission::pri nt() const
{
cout << "Commision employee :"
<< getFirtName() << ' ' << getLastName()
<< "\nsocial security number :" << getSocialSecuri tyNumber()
<< "\ngross sales :" << getGrossSales()
<< "\ncommissi on rate :" << getCommissionRa te();
}


//base class member function definitions
#include <iostream>
using std::cout;

#include "base.h"

Base::Base(cons t string &first,const string &last,const string &ssn,double,dou ble,double)
:Commission(fir st,last,ssn,sal es,rate)
{
setBaseSalary(s alary);
}

void Base::setBaseSa lary(double salary)
{
baseSalary = (salary<0.0) ? 0.0 ? salary;
}

double Base::getBaseSa lary() const
{
return baseSalary;
}

double Base::earnings( ) const
{
return getBaseSalary() + Commission::ear nings(9;
}

void Base::print() const
{
cout << "base salaried ";

Commission::pri nt();

cout < "\nbase salary: " << getBaseSalary() ;
}


//test main
#include <iostream>
using namespace std;

#include <iomanip>
using std::setprecisi on;

#include "base.h"

int main()
{

Commission x("Sue","Jones" ,"2222-1111",10000,.06 );

Commission *xPtr = 0;

Base y("Bob","Lewis" ,"33-3333",5000,.04, 300);
Base *yPtr = 0;

cout << fixed << setprecision(20 );

x.print();
cout << "\n\n";
y.print();

xPtr = &x;
xPtr->print();

yPtr = &y;
yPtr->print();

xPtr = &y;
xPtr->print();

return 0;
}


and I find this errorr ...

C:\Program Files\Microsoft Visual Studio\MyProjec ts\poly\commiss ionsource.cpp(8 ) : error C2511: 'Commission::Co mmission' : overloaded member function 'void (const class std::basic_stri ng<char,struct std::char_trait s<char>,class std::allocator< char>
> &,const class std::basic_stri ng<char,struct std::char_trait s<char>,class std::allocator< char> > &,const class std::basic_stri ng<char,struct std::char_trait s<char>,class std::allocator< char> > &,double,double )' not found in 'Commission'
c:\program files\microsoft visual studio\myprojec ts\poly\commiss ion.h(9) : see declaration of 'Commission'
C:\Program Files\Microsoft Visual Studio\MyProjec ts\poly\commiss ionsource.cpp(8 0) : fatal error C1004: unexpected end of file found
basesource.cpp
C:\Program Files\Microsoft Visual Studio\MyProjec ts\poly\basesou rce.cpp(8) : error C2511: 'Base::Base' : overloaded member function 'void (const class std::basic_stri ng<char,struct std::char_trait s<char>,class std::allocator< char> > &,const class st
d::basic_string <char,struct std::char_trait s<char>,class std::allocator< char> > &,const class std::basic_stri ng<char,struct std::char_trait s<char>,class std::allocator< char> > &,double,double ,double)' not found in 'Base'
c:\program files\microsoft visual studio\myprojec ts\poly\base.h( 11) : see declaration of 'Base'
C:\Program Files\Microsoft Visual Studio\MyProjec ts\poly\basesou rce.cpp(37) : fatal error C1004: unexpected end of file found
main.cpp
C:\Program Files\Microsoft Visual Studio\MyProjec ts\poly\main.cp p(13) : error C2664: '__thiscall Commission::Com mission(const class std::basic_stri ng<char,struct std::char_trait s<char>,class std::allocator< char> > &,const class std::basic_stri ng<cha
r,struct std::char_trait s<char>,class std::allocator< char> > &,const class std::basic_stri ng<char,struct std::char_trait s<char>,class std::allocator< char> > &,const class std::basic_stri ng<char,struct std::char_trait s<char>,class std::allocator< char
> > &,double,double )' : cannot convert parameter 4 from 'const int' to 'const class std::basic_stri ng<char,struct std::char_trait s<char>,class std::allocator< char> > &'
Reason: cannot convert from 'const int' to 'const class std::basic_stri ng<char,struct std::char_trait s<char>,class std::allocator< char> >'
No constructor could take the source type, or constructor overload resolution was ambiguous
C:\Program Files\Microsoft Visual Studio\MyProjec ts\poly\main.cp p(17) : error C2664: '__thiscall Base::Base(cons t class std::basic_stri ng<char,struct std::char_trait s<char>,class std::allocator< char> > &,const class std::basic_stri ng<char,struct std
::char_traits<c har>,class std::allocator< char> > &,const class std::basic_stri ng<char,struct std::char_trait s<char>,class std::allocator< char> > &,const class std::basic_stri ng<char,struct std::char_trait s<char>,class std::allocator< char> > &,double
,double,double) ' : cannot convert parameter 4 from 'const int' to 'const class std::basic_stri ng<char,struct std::char_trait s<char>,class std::allocator< char> > &'
Reason: cannot convert from 'const int' to 'const class std::basic_stri ng<char,struct std::char_trait s<char>,class std::allocator< char> >'
No constructor could take the source type, or constructor overload resolution was ambiguous
C:\Program Files\Microsoft Visual Studio\MyProjec ts\poly\main.cp p(32) : error C2440: '=' : cannot convert from 'class Base *' to 'class Commission *'
Types pointed to are unrelated; conversion requires reinterpret_cas t, C-style cast or function-style cast
Error executing cl.exe.
Dec 24 '07 #1
1 3005
weaknessforcats
9,208 Recognized Expert Moderator Expert
Expand|Select|Wrap|Line Numbers
  1. //The member definition:
  2. Commission::Commission(const string &first,const string &last,const string &ssn,double sales,double rate)
  3.  
Expand|Select|Wrap|Line Numbers
  1. //the class declaration:
  2. Commission(const string &,const string &,const string &,const string &,double=0.0,double=0.0);
  3.  
For starters, the constructor in your class has 4 string& arguments but the construcor definition has only 3.

Fix that and repost if you still have problems.
Dec 24 '07 #2

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

Similar topics

5
6876
by: Andy Jarrell | last post by:
I'm trying to inherit from a specific class that has an overloaded operator. The problem I'm getting is that certain overloaded operators don't seem to come with the inheritance. For example: // TestA.h --------------------------------------- #include <iostream> enum Aval { FIRST_VALUE,
4
1809
by: August1 | last post by:
I've written an interface and implementation file along with a client source file that allows the use of an overloaded subtraction operator. However, when using the program, I'm running into a memory problem that I'm not readily seeing that lies within the overloaded operator - I think pertaining to the temporary class object that is created and used to return a value of the operands and the pointer variable of the class. Could someone...
1
2216
by: masood.iqbal | last post by:
I have a few questions regarding overloaded typecast operators and copy constructors that I would like an answer for. Thanks in advance. Masood (1) In some examples that I have seen pertaining to casting class A to class B, the implementation of the
2
1679
by: Tony Johansson | last post by:
Hello Experts!! I have two small classes called Intvektor and Matris shown at the bottom and a main. Class Intvektor will create a one dimension array of integer by allocate memory dynamically as you can see in the constructor. Class Matris should create a matris by using class Intvektor. So what I want to have is a pointer to an array of Intvektor and in each positionindex in this array will I have a pointer to an array of Intvektor
0
3637
by: Scott Chang | last post by:
Hi all, I tried to use Managed C++ coding of VC++.NET (2002)and OpenGL version 1.2 to draw a hexagon shape of benzene. My OpenGLdrawBenzene.cpp is the following: // This is the main project file for VC++ application project // generated using an Application Wizard. #include "stdafx.h" #include <stdlib.h>
2
1946
by: raylopez99 | last post by:
I'm having problems compiling complex reference declarations in MSVC++.NET 2002 IDE. Here is an example: // --Foo.h-- #include "Bar.h" class Bar; //forward decl. to a class Bar in another file, not used
2
7361
by: B. Williams | last post by:
I have an assignment for school to Overload the operators << and >and I have written the code, but I have a problem with the insertion string function. I can't get it to recognize the second of number that are input so it selects the values from the default constructor. Can someone assist me with the insertion function. The code is below. // Definition of class Complex #ifndef COMPLEX1_H
5
2284
by: raylopez99 | last post by:
I need an example of a managed overloaded assignment operator for a reference class, so I can equate two classes A1 and A2, say called ARefClass, in this manner: A1=A2;. For some strange reason my C++.NET 2.0 textbook does not have one. I tried to build one using the format as taught in my regular C++ book, but I keep getting compiler errors. Some errors claim (contrary to my book) that you cannot use a static function, that you must...
6
4163
by: Joe HM | last post by:
Hello - I have a question regarding overloading the New() in a MustInherit Class. The following show the code in question ... MustInherit Class cAbstract Public MustOverride Sub print() Protected mName As String
0
7923
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
8216
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...
0
8349
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
5719
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
5395
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3882
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2364
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
1
1455
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1192
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.