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:
* Get free support
* Communicate privately with other members (PM).
* Removal of this message
* 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
Go Back   Tech Support Forum > The IT Pro > Programming
User Name
Password
Site Map Register Donate Rules Blogs Mark Forums Read


Programming A discussion forum for programs and programming used in tech-related businesses.

Reply
 
LinkBack Thread Tools
Old 05-29-2009, 05:41 AM   #1 (permalink)
Registered User
 
Join Date: May 2009
Posts: 6
OS: 2


Post 1 error

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;
}
When compile 1 error appear:
"Could not find a match for 'Secretary:Secretary()'
Help me !

Last edited by effective; 05-29-2009 at 05:44 AM.
effective is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
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

Old 05-29-2009, 09:49 AM   #2 (permalink)
Design Team Member
 
jamiemac2005's Avatar
 
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)
Basically, i can see how that would lead the compiler to not registering it as a function/method if it lacks a return type.

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.
__________________

Myspace

Last edited by jamiemac2005; 05-29-2009 at 09:51 AM.
jamiemac2005 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 05-29-2009, 08:00 PM   #3 (permalink)
Registered User
 
Join Date: May 2009
Posts: 6
OS: 2


Re: 1 error

Quote:
Originally Posted by jamiemac2005 View Post
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)
Basically, i can see how that would lead the compiler to not registering it as a function/method if it lacks a return type.

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.
Not correct
effective is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 05-29-2009, 11:46 PM   #4 (permalink)
TSF Enthusiast
 
TheOutcaste's Avatar
 
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;
Looks like you haven't provided any data for Secretary as you have for Manager and Employee
__________________
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?
TheOutcaste is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 05-30-2009, 08:28 AM   #5 (permalink)
Manager
 
shuuhen's Avatar
 
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

My System

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.
shuuhen is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 05-30-2009, 09:39 AM   #6 (permalink)
Design Team Member
 
jamiemac2005's Avatar
 
Join Date: Jul 2007
Location: Coventry, UK
Posts: 1,853
OS: Vista, various linux distros


Re: 1 error

Oh right, nope i get it now haha. Kind of stabbing in the dark with C++.
__________________

Myspace
jamiemac2005 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -7. The time now is 05:40 AM.



Copyright 2001 - 2009, Tech Support Forum
Home Tips Plus | Outdoor Basecamp | Automotive Support Forum

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85