954,500 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

class code

how can I check the donor if valid by using switch
function Is_BloodBroup_Valid // takes a string as parameter and return true if it is a valid
group and false if not. The only possible blood groups are A+, A-, B+, B-, 0+, 0-,
AB+, AB-.

also if I have a Constructor function with default values and one of the parameters was of struct type how I can assign value to it , like this
1. Constructor function with default values IdNumber = 0, name = "", bloodGroup = "",
home_Phone="", mobile_Phone="", address={0,0,0,"",""} An overloaded constructor that takes the same parameters of the constructor in except
Address for the address
this was my try

struct Address {
	int house ,road ,block;
	string city,country;
}add;
BloodDonor(int  =0,string  =" ",string =" ",string =" ",int add.house=0,int add.road=0,);


there are some errors.

bis student
Newbie Poster
16 posts since Dec 2007
Reputation Points: 10
Solved Threads: 0
 

Why not use an enum for the blood type instead? That way you don't have to validate a random string.

Narue
Bad Cop
Administrator
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
 

Try this as ur default contructor signature:

BloodDonor(int id=0,string name=" ",string bGroup=" ",string hPhone=" ",string mPhone="", Address myAdd={0,0,0,"",""});

Luckychap
Posting Pro in Training
444 posts since Aug 2006
Reputation Points: 83
Solved Threads: 61
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You