473,544 Members | 1,822 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 2996
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
6874
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
1805
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...
1
2211
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
1676
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...
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
1943
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
7355
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. ...
5
2277
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...
6
4162
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
7431
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...
0
7370
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7617
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. ...
1
7387
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...
0
5920
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...
1
5305
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...
0
3424
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...
1
1848
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
992
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.