Category : C++ Source Code
Archive   : CPPTUT.ZIP
Filename : CLAS.CPP

 
Output of file : CLAS.CPP contained in archive : CPPTUT.ZIP
// Chapter 5 - Program 2
#include

class one_datum {
int data_store;
public:
void set(int in_value);
int get_value(void);
};

void one_datum::set(int in_value)
{
data_store = in_value;
}

int one_datum::get_value(void)
{
return data_store;
}

main()
{
one_datum dog1, dog2, dog3;
int piggy;

dog1.set(12);
dog2.set(17);
dog3.set(-13);
piggy = 123;

// dog1.data_store = 115; This is illegal in C++
// dog2.data_store = 211; This is illegal in C++

cout << "The value of dog1 is " << dog1.get_value() << "\n";
cout << "The value of dog2 is " << dog2.get_value() << "\n";
cout << "The value of dog3 is " << dog3.get_value() << "\n";
cout << "The value of piggy is " << piggy << "\n";
}




// Result of execution
//
// The value of dog1 is 12
// The value of dog2 is 17
// The value of dog3 is -13
// The value of piggy is 123


  3 Responses to “Category : C++ Source Code
Archive   : CPPTUT.ZIP
Filename : CLAS.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/