quest4tech.net

 

A Basic Class Example

class BankAccount
{
private:
     char name[20];
     char * nam_ptr;
public:
     BankAccount()
     {
          nam_ptr=name;
     }
     char * assignName()
     {
          strcpy(name,"A N Other");
          cout << "\n input = " << name;
          return nam_ptr;
     }
};

void main()
{
     BankAccount account;

     char * ch = account.assignName();
     cout << "output = " << ch;
     getche();
}


 
 
 
 
 
 
 
// declare variables
 
 
 
 
 
 
 
// simulate assigning name to account
 
 
 
 
 
 
 
 
// instantiate an object of the class
 
// call the function assignName() from the object
// print account name.
// type any character to finish program.
 

 

Return to Top

c-cpp index

quest4tech index

(c) Compiled by B V Wood.

 Main Index

UK SPONSERS

 
USA SPONSERS