Category : C Source Code
Archive   : ANSICPP.ZIP
Filename : EX06005.CPP

 
Output of file : EX06005.CPP contained in archive : ANSICPP.ZIP
// ex06005.cpp
// Reference parameters reduce overhead
#include

// ---------- a big structure
struct bigone {
int serno;
char text[1000]; // a lot of chars
} bo = { 123, "This is a BIG structure"};

// -- two functions that have the structure as a parameter
void slowfunc(bigone p1); // call by value
void fastfunc(bigone& p1); // call by reference

main()
{
slowfunc(bo); // this will take a while
fastfunc(bo); // this will be a snap
}

// ---- a call-by-value function
void slowfunc(bigone p1)
{
cout << '\n' << p1.serno;
cout << '\n' << p1.text;
}

// ---- a call by reference function
void fastfunc(bigone& p1)
{
cout << '\n' << p1.serno;
cout << '\n' << p1.text;
}


  3 Responses to “Category : C Source Code
Archive   : ANSICPP.ZIP
Filename : EX06005.CPP

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/