English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

default constructor - set names to empty string and balance to zero
constructor that uses names only-default balance to zero
constructor with names and a beginning balnce

1. What are samples of how those would look like with these objects?

Declare these objects:
obj1 Sam donner with a balance of 2500
obj2 cheryl polk with no intial balnce
obj3 no name or balance

savings(); // obj 3
savings(string f, string l); //obj2
savings(string ff, string ll, float bal); // obj1

2007-02-14 06:40:45 · 3 answers · asked by COD 3 in Computers & Internet Programming & Design

3 answers

Savings obj1("Sam", "Donner",2500);
Savings obj2("Cheryl","Polk");
Savings obj3;

2007-02-14 07:01:16 · answer #1 · answered by MartinPalermo 3 · 0 0

//copy,compile and run

#include
#include

class savings
{
private:
char name[20];
int balance;
public:
savings()
{
strcpy(name,""); balance=0;
}
savings(char temp[])
{
strcpy(name,temp); balance=0;
}
savings(char temp[],int b)
{
strcpy(name,temp); balance=b;
}
~savings()
{
printf("\nName: %s Balance:%d",name,balance);
}
};
void main()
{
savings obj3,obj2("Cheryl polk"),obj1("Sam donner",2500);
}

2007-02-14 15:00:58 · answer #2 · answered by KillingJoke 3 · 0 0

look up "struct" because you could use that to get what you want.

2007-02-14 14:46:00 · answer #3 · answered by bonesawosu 2 · 0 0

fedest.com, questions and answers