#include // import Math using namespace std; //introduces namespace std /// int f(int x); // prototype int f(int x) { return x*x; } class account { private: int balance; public: account(int initial) {balance = initial;} void withdraw(int amt) {balance = balance - amt; } void deposit(int amt) { balance = balance + amt;} int inquiry() { return balance; } }; // extra ; class cell { public: int head; cell *tail; cell(int h, cell *t) { head = h; tail = t; } }; // end class cell int length(cell *l) { if (l == 0) // l == null return 0; else return 1 + length(l->tail); } class bigobject {public: int A[1000]; // array of 1000 integers bigobject() { for (int i=0;i<1000;i++) A[i] = i; } ~bigobject() { } }; // end bigobject int slength(char *s) // same as char s[] { int ax; // accumulator int i; // array index ax = 0; i = 0; while ( s[i] != (char) 0 ) { ax++; i++; } return ax; } // end slength int main( void ) { // account myaccount = new account(500); // pointers /* account *myaccount; // a pointer! account *youraccount; myaccount = new account(500); youraccount = new account(600); myaccount->withdraw(30); cout << (*myaccount).inquiry(); cell *c; c = new cell(3,new cell(5, new cell(7,0))); cout << length(c); int i, j; bigobject *b; for(i=0;i<10000;i++) for(j=0;j<100000;j++) { b = new bigobject(); delete(b); } cout << "done\n"; */ char *a; a = "abcdefg"; cout << slength(a); return 0; }