C++ World

C++ Resources, Tips,
Documentation, Examples,
HOWTO's, FAQ's, Tools
Libraries, Frameworks, IDE's

 
© 2005,2009 C++ World - All rights reserved - webdesign.arttina
C++, Sockets, SysProg, Libraries, Examples, Tools, Compilers, IDE, STL, XML
Google
FAQ Sockets Socket Library Software Engineering Sysprog Examples Books
 
Home
C++
The C Language
STL
BOOST
GNU
GNU C Compiler
GNU Debugger
GNU Profiler
HP C++ Compiler
DDD
Eclipse
Curses
XML
X11
KDevelop
MS Visual Studio
Tutorials
// *************************************************
// File: simpleexample.cpp
// Author: franzbrandel@cplusplusworld.com
// (c) 2009 C++ World
// http://www.cplusplusworld.com/
// simple example
// *************************************************

#include <iostream>

class Busy {
 
  private:
	int Counter;

  public:
	
	// Destructor
	virtual ~Busy() {
	}

	// constructor
	Busy() {
	 Counter = 0;
	}

	void Loop ( int howoften ) {
	 for ( int i = 0; i < howoften; ++ i ) 
		++ Counter ;
	}

	int GetCounter ( ) {
	 return Counter;
	}
};

int main ( int argc, char * argv [] ) {
 Busy B1;
 Busy B2;

 B1.Loop ( 1000 );
 B2.Loop ( 1000000 );

 std::cout << "Counter in B1 is now " << B1.GetCounter() << "\n";
 std::cout << "Counter in B2 is now " << B2.GetCounter() << "\n";

 return 0;
}



syntax highlighted by Code2HTML, v. 0.9.1


Franz Brandel Contact Legal Statement Sitemap C++ World