![]() |
![]() |
![]() |
|||||
![]() |
![]() |
![]() |
![]() |
![]() |
|||
| Welcome
to Tech Support Forum home to more then 136,000 problems solved. Issues
have included: Spyware, Malware, Virus Issues, Windows, Microsoft,
Linux, Networking, Security, Hardware, and Gaming Getting your
problem solved is as easy as: 1. Registering for a free account 2. Asking your question 3. Receiving an answer Registered members: * See fewer ads. * And much more..
|
| Want to know how to post a question? click here | Having problems with spyware and pop-ups? First Steps |
|
|||||||
| Programming A discussion forum for programs and programming used in tech-related businesses. |
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 (permalink) |
|
Registered User
Join Date: May 2009
Posts: 6
OS: 2
|
Code:
#include<iostream.h>
#include<string.h>
#include<conio.h>
const int len=30;
enum contract{permanent,temporary};
class Employee{
protected:
char name[len];
long int ID;
double salary;
public:
Employee() **}
Employee(char n[len],long int id, double s)**
strcpy(name,n);
ID=id;
salary=s;}
void setEmp(char [len],long int id,double s) **
cout<<"\nName of Employee: "<<name;
cout<<"\nID of Employee: "<<ID;
cout<<"\nSalary of Employee: "<<salary;
}
friend ostream& operator << (ostream&,Employee &);
};
ostream& operator << (ostream & out,Employee & n) **
out <<n.name<<"----" <<n.ID<<"-----"<<n.salary<<endl;
return out;
}
class Manager: public Employee **
private:
char degree[len];
public:
Manager (char n[len],long int id,double s,char d[len])**
Employee::Employee(n,id,s);
strcpy(degree,d);}
void setEmp(char n[len], long int id, double s, char d)**
Employee::setEmp(n,id,s);
cout<<"\nDegree of Employee: "<<degree;
}
friend ostream& operator << (ostream&,Manager &);
};
ostream& operator << (ostream & out,Manager & n) **
out <<n.name<<"----" <<n.ID<<"-----"<<n.salary<<"-----"<<n.degree<<endl;
return out;
}
class Secretary: public Employee **
private:
contract contractType;
public:
Secretary(char n[len],long int id, double s,contract c)**
Employee::Employee(n,id,s);
contractType=c;}
void setEmp(char n[len], long int id, double s, contract c)**
Employee::setEmp(n,id,s);
cout<<"\nContract Type of Employee: "<<contractType;
}
friend ostream& operator << (ostream&,Secretary &);
};
ostream& operator << (ostream & out,Secretary & n) **
out <<n.name<<"----" <<n.ID<<"-----"<<n.salary<<"----"<<n.contractType<<endl;
return out;
}
int main() **
Employee p( "Silva", 1234567, 500.0);
Manager p1( "Silva Mikaido",234567, 1000.0, "Dr.");
Secretary p2;
p2.setEmp( "Sizer", 341256, 400.0,permanent);
cout<< "Manager p1 is "<<p1;
cout<< "Secretary p2 is "<<p2;
return 0;
}
"Could not find a match for 'Secretary:Secretary()' Help me ! Last edited by effective; 05-29-2009 at 05:44 AM. |
|
|
|
| Important Information |
|
Join the #1 Tech Support Forum Today - It's Totally Free!
TechSupportForum.com is a leading support website for your computer needs. We offer free, friendly and personalized computer support. Why pay to have your computer fixed when you can do it for free. Join TechSupportforum.com Today - Click Here |
|
|
#2 (permalink) |
|
Design Team Member
Join Date: Jul 2007
Location: Coventry, UK
Posts: 1,853
OS: Vista, various linux distros
|
Re: 1 error
Hey, not much of a C++ guy myself, but i think i have your answer(If i'm wrong, tell me so):
Your Secretary method has no return type... Should it? something like: Code:
void Secretary(char n[len],long int id, double s,contract c) Cheers, Jamey p.s. it could also be that you have the same identifier name for a class and a public method. But again, i'm not certain. Last edited by jamiemac2005; 05-29-2009 at 09:51 AM. |
|
|
|
|
|
#3 (permalink) | |
|
Registered User
Join Date: May 2009
Posts: 6
OS: 2
|
Re: 1 error
Quote:
|
|
|
|
|
|
|
#4 (permalink) |
|
TSF Enthusiast
Join Date: Mar 2009
Location: Portland, OR
Posts: 761
OS: MS-Dos 6.22 - Win7
|
Re: 1 error
Just a guess as I know next to nothing about C++, but I can see this difference:
Code:
Employee p ( "Silva", 1234567, 500.0); Manager p1 ( "Silva Mikaido",234567, 1000.0, "Dr."); Secretary p2;
__________________
Microsoft MVP - Windows Desktop Experience Of course I know all the answers; I just don't always match the answers to the right questions. Rated R for Violence -- When your PC flies through a window, that's violent, right? |
|
|
|
|
|
#5 (permalink) |
|
Manager
Join Date: Sep 2004
Location: Colorado
Posts: 980
OS: Mac OS 9.1, Mac OS X 10.5.8, WinXP Pro, FreeBSD 6.0, Gentoo Linux
|
Re: 1 error
I'm guessing you are assuming that Secretary would inherit the constructors from Employee? This is not exactly what happens. If a derrived class does not have any constructors, the complier will generate one. Since Secretary has a constructor, you'll need to specify any other constructors.
Just wondering, why have conio.h? It doesn't appear to be used. Also, any reason you're using "#include <iostream.h>" (deprecated) instead of "#include <iostream>" (current)? @jamiemac2005: The Secretary method is a constructor, so it does not have a return type. @TheOutcaste: The declaration of the Secretary variable would implicitly call a constructor with no arguments. It fails since that constructor is not defined.
__________________
![]() Has it been a few days since I replied to your thread? Don't panic! I'm a busy college student and may forget a post if I'm extra busy (or it might just take me a while to be able to do a decent reply). If you still need help and are awaiting my reply after a few days, PM me about it. When posting what errors you get, please give the full message. It makes helping you much easier. |
|
|
|
![]() |
| Thread Tools | |
|
|