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

Erros: Overloaded constructor not found, EOF found

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(const string &,const string &,const string &,const string &,double=0.0,double=0.0);

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

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

void setSocialSecurityNumber(const string &);
string getSocialSecurityNumber() const;

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

void setCommissionRate(double);
double getCommissionRate() const;

double earnings() const;
void print() const;
private:
string firstName;
string lastName;
string socialSecurityNumber;
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,double=0.0,double=0.0);
void setBaseSalary(double);
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::Commission(const string &first,const string &last,const string &ssn,double sales,double rate)
:firstName(first),lastName(last),socialSecurityNum ber(ssn)
{
setGrossSales(sales);
setCommissionRate(rate);
}

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

string Commission::getFirstName() const
{
return firstName;
}

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

string Commission::getLastName() const
{
return lastName;
}

void Commission::setSocialSecurityNumber(const string &ssn)
{
socialSecurityNumber = ssn;
}

string Commission::getSocialSecurityNumber() const
{
return socialSecurityNumber;
}

void Commission::setGrossSales(double sales)
{
grossSales = (sales<0.0 ? 0.0 : sales);
}

double Commission::getGrossSales() const
{
return grossSales;
}

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

double Commission::getCommissionRate() const
{
return grossRate;
}

double Commission::earnings() const
{
return getCommissionRate() * getGrossSales();
}

void Commission::print() const
{
cout << "Commision employee :"
<< getFirtName() << ' ' << getLastName()
<< "\nsocial security number :" << getSocialSecurityNumber()
<< "\ngross sales :" << getGrossSales()
<< "\ncommission rate :" << getCommissionRate();
}


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

#include "base.h"

Base::Base(const string &first,const string &last,const string &ssn,double,double,double)
:Commission(first,last,ssn,sales,rate)
{
setBaseSalary(salary);
}

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

double Base::getBaseSalary() const
{
return baseSalary;
}

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

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

Commission::print();

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


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

#include <iomanip>
using std::setprecision;

#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\MyProjects\poly\commissionsource.cpp(8) : error C2511: 'Commission::Commission' : overloaded member function 'void (const class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char>
> &,const class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &,const class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &,double,double)' not found in 'Commission'
c:\program files\microsoft visual studio\myprojects\poly\commission.h(9) : see declaration of 'Commission'
C:\Program Files\Microsoft Visual Studio\MyProjects\poly\commissionsource.cpp(80) : fatal error C1004: unexpected end of file found
basesource.cpp
C:\Program Files\Microsoft Visual Studio\MyProjects\poly\basesource.cpp(8) : error C2511: 'Base::Base' : overloaded member function 'void (const class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &,const class st
d::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &,const class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &,double,double,double)' not found in 'Base'
c:\program files\microsoft visual studio\myprojects\poly\base.h(11) : see declaration of 'Base'
C:\Program Files\Microsoft Visual Studio\MyProjects\poly\basesource.cpp(37) : fatal error C1004: unexpected end of file found
main.cpp
C:\Program Files\Microsoft Visual Studio\MyProjects\poly\main.cpp(13) : error C2664: '__thiscall Commission::Commission(const class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &,const class std::basic_string<cha
r,struct std::char_traits<char>,class std::allocator<char> > &,const class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &,const class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char
> > &,double,double)' : cannot convert parameter 4 from 'const int' to 'const class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &'
Reason: cannot convert from 'const int' to 'const class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >'
No constructor could take the source type, or constructor overload resolution was ambiguous
C:\Program Files\Microsoft Visual Studio\MyProjects\poly\main.cpp(17) : error C2664: '__thiscall Base::Base(const class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &,const class std::basic_string<char,struct std
::char_traits<char>,class std::allocator<char> > &,const class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &,const class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &,double
,double,double)' : cannot convert parameter 4 from 'const int' to 'const class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &'
Reason: cannot convert from 'const int' to 'const class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >'
No constructor could take the source type, or constructor overload resolution was ambiguous
C:\Program Files\Microsoft Visual Studio\MyProjects\poly\main.cpp(32) : error C2440: '=' : cannot convert from 'class Base *' to 'class Commission *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Error executing cl.exe.
Dec 24 '07 #1
1 2983
weaknessforcats
9,208 Expert Mod 8TB
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
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: ...
4
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...
1
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...
2
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...
0
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...
2
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...
2
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...
5
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...
6
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() ...
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
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
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...
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
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...
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,...

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.