Did you think (grin) I had gone away. No. As I told you,
you guys in your examples have me saving some of them for later
while I work on basics.
I've finally gotten smart and placed my includes in a
separate include that I don't have to type over and over again. So,
generally, I won't send it with the main program. This time, I
will:
// class.hpp
#include
#include
#include
#include
// and the main program:
#include "class.hpp"
class database
{
private:
char name[30];
char address[60];
char city[20];
char state[2];
char zip[10];
public:
void getdata(char a[], char c[], char s[], char z[])
{
strcpy(address,a);
strcpy(city,c);
strcpy(state,s);
strcpy(zip, z);
}
void showdata()
{
cout > name;
cout << '\n';
cout << "Address= " << address << endl;
cout << "City= " << city << endl;
cout << "State= " << state << endl;
cout << "Zip code= " << zip << endl;
}
};
main()
{
clrscr();
database d;
d.getdata ( "5713 York", "Metairie", "La", "70003-2019");
d.showdata();
return 0;
}
I'm really working through Chapter 7 of Lafore's book on C++
(the chapter on Classes and Objects) but I can't help when I notice
that ALL of the examples deal ONLY with ints and I want to see how
to use chars for some strings. Thus, I looked at some examples
elsewhere and put the above together.
I purposely made it so I could input ONE of the data items
and just set up the rest as constants. There really is only one
name living at this address!!!
Also, when I expanded the tabs after importing the code I
noted that my setting of 8 for the tabs is to big. I'll fix that.
Sincerely,
Frank
Any comments any of you care to make will be welcome. Be as
tough as you want to. I want to learn and my year is growning
short!
--- PPoint 2.03
---------------
* Origin: Maybe in 5,000 years - frankmas@juno.com (1:396/45.12)
|