summaryrefslogtreecommitdiff
path: root/reference/CPLUSPLUS/EXAMPLES
diff options
context:
space:
mode:
Diffstat (limited to 'reference/CPLUSPLUS/EXAMPLES')
-rw-r--r--reference/CPLUSPLUS/EXAMPLES/MGREP.CC854
-rw-r--r--reference/CPLUSPLUS/EXAMPLES/Makefile.am5
-rw-r--r--reference/CPLUSPLUS/EXAMPLES/Makefile.in410
-rw-r--r--reference/CPLUSPLUS/EXAMPLES/cast.cc18
-rw-r--r--reference/CPLUSPLUS/EXAMPLES/class1.cc39
-rw-r--r--reference/CPLUSPLUS/EXAMPLES/class2.cc53
-rw-r--r--reference/CPLUSPLUS/EXAMPLES/const1.cc46
-rw-r--r--reference/CPLUSPLUS/EXAMPLES/enum1.c23
-rw-r--r--reference/CPLUSPLUS/EXAMPLES/enum1.cc23
-rw-r--r--reference/CPLUSPLUS/EXAMPLES/inherit.cc116
-rw-r--r--reference/CPLUSPLUS/EXAMPLES/inline.cc15
-rw-r--r--reference/CPLUSPLUS/EXAMPLES/io1.cc19
-rw-r--r--reference/CPLUSPLUS/EXAMPLES/io2.cc27
-rw-r--r--reference/CPLUSPLUS/EXAMPLES/mjl_test.cc27
-rw-r--r--reference/CPLUSPLUS/EXAMPLES/new.cc39
-rw-r--r--reference/CPLUSPLUS/EXAMPLES/overload.cc27
-rw-r--r--reference/CPLUSPLUS/EXAMPLES/refvar.cc26
-rw-r--r--reference/CPLUSPLUS/EXAMPLES/scope.cc27
-rw-r--r--reference/CPLUSPLUS/EXAMPLES/struct1.cc53
-rw-r--r--reference/CPLUSPLUS/EXAMPLES/throw.cc43
20 files changed, 1890 insertions, 0 deletions
diff --git a/reference/CPLUSPLUS/EXAMPLES/MGREP.CC b/reference/CPLUSPLUS/EXAMPLES/MGREP.CC
new file mode 100644
index 0000000..6052afd
--- /dev/null
+++ b/reference/CPLUSPLUS/EXAMPLES/MGREP.CC
@@ -0,0 +1,854 @@
+/************************************************************************
+ *
+ * Purpose:
+ * Author: M J Leslie
+ * Date: 26-Oct-98
+ *
+ ************************************************************************/
+
+
+/* Known problems.
+
+ Serious memory leaks
+ not enough comments
+ Has problems with vi swp files on Linux (so does normal grep).
+
+*/
+
+
+extern "C"
+{
+#include <stdio.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <ctype.h>
+#include <stdlib.h>
+#include <unistd.h>
+}
+
+#include <iostream.h>
+
+// DEBUG 1 == Debugging information is required.
+// DEBUG 0 == Debugging info is suppresed.
+
+#define DEBUG 0
+
+class List
+{
+public:
+ List()
+ {
+ Reset();
+ }
+
+ ~List()
+ {
+ }
+
+ void Add(int Number)
+ {
+ Add(Number, ':');
+ }
+
+ void Add(int Number, char Prefix)
+ {
+ // Are we adding the first item in the list?
+
+ if ( pFirstItem == 0 )
+ {
+ // Yes.
+
+ pFirstItem = new IntList;
+ pCurrentItem = pFirstItem;
+ }
+ else
+ {
+ // No. Add the number to the end of the list.
+
+ pCurrentItem->pNext = new IntList;
+ pCurrentItem = pCurrentItem->pNext;
+ }
+
+ pCurrentItem->Item = Number;
+ pCurrentItem->Prefix = Prefix;
+ pCurrentItem->pNext = 0;
+ }
+
+ void PointToFirstEntry(void)
+ {
+ pCurrentItem = pFirstItem;
+ }
+
+ void Reset(void)
+ {
+ // This is going to cause seriuos memory leaks!
+
+ pFirstItem = 0;
+ pCurrentItem = 0;
+ }
+
+ int GetCurrentEntry(void)
+ {
+ // Check we have a valid Item.
+
+ if (pCurrentItem)
+ {
+ return (pCurrentItem->Item);
+ }
+ else
+ {
+ // No Item. This could happen when the list is empty.
+
+ return (0);
+ }
+ }
+
+ int GetNextEntry(void)
+ {
+ // Is there another entry in the list?
+
+ if ( pCurrentItem->pNext != 0 )
+ {
+ // Yes. Give it to the caller.
+
+ pCurrentItem = pCurrentItem->pNext;
+
+ return (pCurrentItem->Item);
+ }
+ else
+ {
+ // No.
+
+ return (0);
+ }
+ }
+
+ char GetCurrentPrefix(void)
+ {
+ // pCurrentItem = pCurrentItem->pNext;
+
+ return (pCurrentItem->Prefix);
+ }
+
+ char GetNextPrefix(void)
+ {
+ pCurrentItem = pCurrentItem->pNext;
+
+ return (pCurrentItem->Prefix);
+ }
+
+private:
+
+ struct IntList
+ {
+ int Item;
+ char Prefix;
+ IntList *pNext;
+ };
+
+ IntList *pFirstItem;
+ IntList *pCurrentItem;
+};
+
+class grep
+{
+public:
+
+ // enum { LL = 512 } LineLength ;
+
+ // .......................................................................
+
+ grep() // Constructor.
+ {
+
+ OFF = 0;
+ ON = 1;
+
+ LineNumbering = ON;
+
+ LinesBefore = 2;
+ LinesAfter = 2;
+
+ LinesInFile = 0;
+
+ pFileName = 0;
+
+ SearchString = '\0';
+ InsensitiveSearch = OFF;
+ }
+
+ // .......................................................................
+
+ ~grep () // Distructor.
+ {
+ delete[] pFileName;
+ }
+
+ // .......................................................................
+
+ void BuildMatrix(void)
+ {
+ int Line = 0;
+ int StartPos = 0;
+ int EndPos = 0;
+ int NextPos = 0;
+
+ Debug("BuildMatrix");
+
+ FoundLines.PointToFirstEntry();
+
+ Line = FoundLines.GetCurrentEntry();
+ Debug(Line);
+
+ // Loop until we run out of line numbers.
+
+ while ( Line > 0 )
+ {
+ // Find the first line to display.
+
+ StartPos = Line - LinesBefore;
+
+ if ( StartPos <= EndPos )
+ {
+ StartPos = EndPos + 1;
+ }
+
+ while ( StartPos < Line )
+ {
+ LineMatrix.Add(StartPos, ':');
+ Debug(StartPos, 's');
+ StartPos++;
+ }
+
+ LineMatrix.Add(Line, '*');
+ Debug(Line, '*');
+
+ EndPos = Line + LinesAfter;
+
+ if ( EndPos > LinesInFile )
+ {
+ EndPos = LinesInFile;
+ }
+
+ NextPos = FoundLines.GetNextEntry();
+
+ if ( NextPos > 0 && EndPos >= NextPos )
+ {
+ EndPos = NextPos - 1;
+ }
+
+ Line++;
+
+ while ( Line <= EndPos )
+ {
+ LineMatrix.Add(Line, ':');
+ Debug(Line, 'e');
+ Line++;
+ }
+
+ Line = NextPos;
+ Debug(Line);
+ }
+ }
+
+ // .......................................................................
+
+ void CaseInsensitive(void)
+ {
+ InsensitiveSearch = ON;
+ }
+
+ // .......................................................................
+
+ void Diagnostic(void)
+ {
+ cout << endl << "Extra lines before the found line: " << LinesBefore << endl;
+
+ if ( InsensitiveSearch )
+ {
+ cout << "Search is: Case Insensitive." << endl;
+ }
+ else
+ {
+ cout << "Search is: Case Sensitive." << endl;
+ }
+ }
+
+ // .......................................................................
+
+ int Exists(void)
+ {
+ // Have we got the file name?
+
+ if ( pFileName == 0 )
+ {
+ // No.
+
+ return (0);
+ }
+ else
+
+ {
+ // Yes. Check the file exists.
+
+ struct stat stat_p; /* 'stat_p' is a pointer to a structure
+ * of type 'stat'. */
+
+ /* Get stats for file and place them in
+ * the structure. */
+
+
+ if ( -1 == stat (pFileName, &stat_p) )
+ {
+ // File name not found.
+
+ return (0);
+ }
+
+ if(!S_ISREG(stat_p.st_mode))
+ {
+ // This is not a regular file. It may be a directory.
+ // Ignore it.
+
+ return(0);
+ }
+
+ // File name is OK.
+
+ return (1);
+ }
+ }
+
+ // .......................................................................
+
+ void Name(char *pFN)
+ {
+ Debug("Name", pFN);
+
+ pFileName = new char[strlen(pFN)+1];
+ strcpy(pFileName, pFN);
+ }
+
+ // .......................................................................
+
+ void NoLineNumbers(void)
+ {
+ LineNumbering = OFF;
+ }
+
+
+ // .......................................................................
+
+ void ProcessFile(void)
+ {
+ int Line;
+ int PreviousLine= 0;
+ char Prefix;
+ int CurrentLine = 0;
+ char Buffer[512];
+ int LineCount = 0;
+
+ FILE *fp;
+
+ Debug("ProcessFile");
+
+ cout << endl << "Search String is: " << SearchString << endl;
+ cout << "File Name is: " << pFileName << endl;
+
+ fp = fopen (pFileName, "r");
+
+ LineMatrix.PointToFirstEntry();
+
+ Line = LineMatrix.GetCurrentEntry();
+ Prefix = LineMatrix.GetCurrentPrefix();
+
+ while ( Line > 0 )
+ {
+ do
+ {
+ fgets(Buffer, 512, fp);
+ LineCount ++;
+ } while ( LineCount < Line );
+
+ // Put in a seperator between blocks.
+
+ if ( PreviousLine+1 < Line )
+ {
+ Seperator();
+ }
+
+ if ( LineNumbering )
+ {
+ cout << Line << Prefix << " " << Buffer;
+ }
+ else
+ {
+ cout << Prefix << " " << Buffer;
+
+ }
+
+ PreviousLine = Line;
+
+ Line = LineMatrix.GetNextEntry();
+ Prefix = LineMatrix.GetCurrentPrefix();
+ }
+
+ Seperator();
+
+ fclose(fp);
+ }
+
+ // .......................................................................
+
+ void PutSearchString(char *String)
+ {
+ Debug("PutSearchString");
+ Debug(String);
+
+ SearchString = new char[strlen(String)+1];
+ strcpy(SearchString, String);
+
+ if ( InsensitiveSearch )
+ {
+ // Yes. Convert the buffer to uppercase.
+
+ Uppercase(SearchString);
+ }
+ }
+
+ // .......................................................................
+
+ void Reset(void)
+ {
+ FoundLines.Reset();
+ LineMatrix.Reset();
+ }
+
+ // .......................................................................
+
+ int ScanFile(void)
+ {
+ FILE *fp;
+ char Buffer[512];
+ int LineCounter = 0;
+ int Found = 0; // Number of lines that matched the search string.
+
+ fp = fopen(pFileName, "r");
+
+ Debug ("ScanFile");
+
+ while ( !feof(fp) )
+ {
+ LineCounter++;
+
+ fgets(Buffer, 512, fp);
+
+ // Check the Buffer was big enough.
+
+ if (strlen(Buffer) == 512 -1 )
+ {
+ cout << __FILE__
+ << ": Warning! Lines in "
+ << pFileName
+ << " exceed the max line length of " << 512 << endl;
+ }
+
+ // Are we doing a case insensitive search?
+
+ if ( InsensitiveSearch )
+ {
+ // Yes. Convert the buffer to uppercase.
+
+ Uppercase(Buffer);
+ }
+
+ if ( strstr(Buffer, SearchString) )
+ {
+ FoundLines.Add(LineCounter);
+ Found++;
+ }
+
+ }
+ fclose (fp);
+
+ LinesInFile = LineCounter;
+
+ return(Found);
+ }
+
+ // .......................................................................
+
+ void SetLines(int Lines)
+ {
+ SetLinesBefore(Lines);
+ SetLinesAfter(Lines);
+ }
+
+ // .......................................................................
+
+ void SetLinesBefore(int Lines)
+ {
+ LinesBefore = Lines;
+ }
+
+ // .......................................................................
+
+ void SetLinesAfter(int Lines)
+ {
+ LinesAfter = Lines;
+ }
+
+private:
+
+ // Debugging methods.
+
+ void Debug(char *Message)
+ {
+ if ( DEBUG )
+ {
+ cout << "Debug: " << Message << endl;
+ }
+ }
+
+ // .......................................................................
+ void Debug(int Value)
+ {
+ if ( DEBUG )
+ {
+ cout << "Debug: " << Value << endl;
+ }
+ }
+
+ // .......................................................................
+
+ void Debug(int Value, char Char)
+ {
+ if ( DEBUG )
+ {
+ cout << "Debug: " << Char << " " << Value << endl;
+ }
+ }
+
+ // .......................................................................
+
+ void Debug(char * Str, int Value)
+ {
+ if ( DEBUG )
+ {
+ cout << "Debug: " << Str << " " << Value << endl;
+ }
+ }
+
+ // .......................................................................
+
+ void Debug(char * Str1, char * Str2)
+ {
+ if ( DEBUG )
+ {
+ cout << "Debug: " << Str1 << " " << Str2 << endl;
+ }
+ }
+
+ // .......................................................................
+
+ // Seperate blocks of data.
+
+ void Seperator(void)
+ {
+ cout << "------" << endl;
+ }
+
+ // .......................................................................
+
+
+ void Uppercase(char *String)
+ {
+ int Offset = 0;
+
+ while ( String[Offset] != (char)NULL )
+ {
+ String[Offset] = toupper(String[Offset]);
+ Offset++;
+ }
+ }
+
+ int LineNumbering; // ON = Line numbering required.
+ int LinesBefore;
+ int LinesAfter;
+
+ int LinesInFile; // Number of lines in the file.
+ int InsensitiveSearch; // ON = Case insensitive search required.
+
+ char *pFileName; // File to be searched.
+ char *SearchString;
+
+ List FoundLines; // List of lines that contain the search string.
+ List LineMatrix; // List of lines that will be displayed.
+
+ // Handy variables to set boolean variables.
+
+ int OFF;
+ int ON;
+
+};
+
+// Private functions.
+
+void Debug(char *Message);
+
+void Help(void);
+
+void ProcessTheCommandLine(
+ int argc,
+ char **Argv);
+
+
+//
+// Start point in the program.
+//
+
+main(
+ int Argc,
+ char **Argv)
+{
+ ProcessTheCommandLine(Argc, Argv);
+}
+
+ // .......................................................................
+
+void Help(void)
+{
+ cout << endl
+ << " mgrep (Martins grep or Multi line grep) is an alternative to grep. " << endl
+ << " The purpose is the same as grep in that it searches files " << endl
+ << " looking for a supplied string. The difference is in the output, " << endl
+ << " aswell as showing the line that contains the string, it also " << endl
+ << " shows the lines around the found line." << endl;
+
+ cout << endl
+ << " When reading from stdin, mgrep works a little differently to grep." << endl
+ << " grep will scan the data on stdin looking for the search string." << endl
+ << " mgrep assumes it is being passed file names, therefore it attempts " << endl
+ << " to open the files and search the contents. " << endl;
+
+ cout << endl
+ << " Please note that mgrep is slower than grep, this is because it " << endl
+ << " performs two passes over the files being searched. " << endl;
+
+ cout << endl
+ << "Syntax:" << endl << endl;
+
+ // cout << " mgrep [ -d -h -l n -b n -a n -s] string [filenames]" << endl;
+ cout << " mgrep [ -d -h -l n -b n -a n ] string [filenames]" << endl;
+ cout << "" << endl;
+ cout << " -h --------- Display this help." << endl;
+ cout << " -d --------- Basic diagnostic information is printed." << endl;
+ cout << " -i --------- Case insensitive search." << endl;
+ cout << " -n --------- No line numbering required." << endl;
+ cout << " -l n ------- Number of lines to show either side of the found line." << endl;
+ cout << " Default is 2." << endl;
+ cout << " -b n ------- Number of lines to show before the found line." << endl;
+ cout << " Default is 2." << endl;
+ cout << " -a n ------- Number of lines to show after the found line." << endl;
+ cout << " Default is 2." << endl;
+ cout << " -s --------- Look for the list of files on STDIN." << endl;
+ cout << " string ----- The string to search for." << endl;
+ cout << " filenames -- List of files to search." << endl << endl;
+}
+
+ // .......................................................................
+
+void Debug(char *Message)
+{
+ if ( DEBUG )
+ {
+ cout << "Debug: " << Message << endl;
+ }
+}
+
+//
+// Read the command line and act on its contents.
+//
+
+void ProcessTheCommandLine(
+ int Argc,
+ char **Argv)
+{
+ grep File;
+
+ int Flag = 'x';
+ int LookAtStdin = 0;
+ int FirstFile = 1;
+ int DiagnosticRequired = 0;
+
+ Debug("ProcessTheCommandLine");
+
+ // Process the command line.
+
+ for ( int Inc = 1; Inc < Argc; Inc++ )
+ {
+ // Have we got a flag?
+
+ if ( *(Argv[Inc]) == '-' )
+ {
+ // Yes.
+
+ Flag = *((Argv[Inc])+1);
+
+ switch ( Flag )
+ {
+ case 'd': // Diagnostics requested
+ DiagnosticRequired = 1;
+ break;
+
+ case 'h': // Help requested
+ Help();
+ exit(0);
+ break;
+
+ case 'i': // Case insensitive search
+ File.CaseInsensitive();
+ break;
+
+ case 'l': // Number of lines to show either side of the found line.
+ Inc++;
+ File.SetLines(atoi(Argv[Inc]));
+ break;
+
+ case 'n':
+ File.NoLineNumbers();
+ break;
+
+ case 'b':
+ Inc++;
+ File.SetLinesBefore(atoi(Argv[Inc]));
+ break;
+
+ case 'a':
+ Inc++;
+ File.SetLinesAfter(atoi(Argv[Inc]));
+ break;
+
+ case 's':
+ LookAtStdin = 1;
+
+ default:
+ cout << Argv[Inc] << " is an invalid flag" << endl;
+ }
+ }
+ else
+ {
+ // This is not a flag, it has to be
+ // the search string or a file name.
+
+ if ( FirstFile )
+ {
+ // Assume the first word following
+ // the flags is the search string.
+
+ File.PutSearchString(Argv[Inc]);
+
+ if ( DiagnosticRequired )
+ {
+ File.Diagnostic();
+ }
+
+ FirstFile = 0;
+ }
+ else
+ {
+ File.Name(Argv[Inc]);
+
+ // ... If the file exists,
+ // ... find and display the lines that contain
+ // ... the search string.
+
+ if ( !File.Exists() )
+ {
+ // cout << "File " << Argv[Inc] << " not found. " << endl;
+ }
+ else
+ {
+ int Found = 0;
+
+ Debug("File Found");
+
+ Found = File.ScanFile();
+
+ // Only proceed with this file if we found matching records.
+
+ if (Found > 0)
+ {
+ File.BuildMatrix();
+ File.ProcessFile();
+ }
+ File.Reset();
+ }
+ }
+ }
+ }
+
+ // Should we scan stdin for file names?
+ // This is a bodge because I cant figure out how to do a non blocking
+ // read on sdtin.
+
+ if (LookAtStdin)
+ {
+ // Yes.
+
+ char FileName[256];
+
+ // check we have a search string before looking in STDIN for filenames.
+
+ if (FirstFile)
+ {
+ cout << __FILE__ << ": Search string not Supplied. " << endl;
+ Help();
+ return;
+ }
+
+ // Disable buffering on stdin. This mean that stdin can be
+ // read without special cmd line flags and fgets does not
+ // lock up the program.
+
+ char Buffer[BUFSIZ];
+
+ // setvbuf(stdin, Buffer);
+
+ // Now check STDIN for file names.
+
+ while (fgets(FileName, 256, stdin))
+ {
+ FileName[strlen(FileName)-1] = '\0';
+ // cout << "stdin loop" << FileName << endl;
+ File.Name(FileName);
+
+ // ... If the file exists,
+ // ... find and display the lines that contain
+ // ... the search string.
+
+ if ( !File.Exists() )
+ {
+ // cout << "File " << FileName << " not found. " << endl;
+ }
+ else
+ {
+ int Found = 0;
+
+ Debug("File Found");
+
+ Found = File.ScanFile();
+
+ // Only proceed with this file if we found matching records.
+
+ if (Found > 0)
+ {
+ File.BuildMatrix();
+ File.ProcessFile();
+ }
+ File.Reset();
+ }
+ }
+ }
+}
+
diff --git a/reference/CPLUSPLUS/EXAMPLES/Makefile.am b/reference/CPLUSPLUS/EXAMPLES/Makefile.am
new file mode 100644
index 0000000..70a7928
--- /dev/null
+++ b/reference/CPLUSPLUS/EXAMPLES/Makefile.am
@@ -0,0 +1,5 @@
+EXTRA_DIST = $(wildcard *.cc) $(wildcard *.CC)
+docs_DATA = $(EXTRA_DIST)
+
+docsdir = $(kde_htmldir)/en/kdevelop/$(subdir)
+
diff --git a/reference/CPLUSPLUS/EXAMPLES/Makefile.in b/reference/CPLUSPLUS/EXAMPLES/Makefile.in
new file mode 100644
index 0000000..ce65d65
--- /dev/null
+++ b/reference/CPLUSPLUS/EXAMPLES/Makefile.in
@@ -0,0 +1,410 @@
+# KDE tags expanded automatically by am_edit - $Revision: 1.2 $
+# Makefile.in generated automatically by automake 1.5 from Makefile.am.
+
+# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
+# Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+SHELL = @SHELL@
+
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+VPATH = @srcdir@
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+
+bindir = @bindir@
+sbindir = @sbindir@
+libexecdir = @libexecdir@
+datadir = @datadir@
+sysconfdir = @sysconfdir@
+sharedstatedir = @sharedstatedir@
+localstatedir = @localstatedir@
+libdir = @libdir@
+infodir = @infodir@
+mandir = @mandir@
+includedir = @includedir@
+oldincludedir = /usr/include
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+top_builddir = ../../..
+
+ACLOCAL = @ACLOCAL@
+AUTOCONF = @AUTOCONF@
+AUTOMAKE = @AUTOMAKE@
+AUTOHEADER = @AUTOHEADER@
+
+INSTALL = @INSTALL@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = @program_transform_name@
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_alias = @build_alias@
+build_triplet = @build@
+host_alias = @host_alias@
+host_triplet = @host@
+target_alias = @target_alias@
+target_triplet = @target@
+AMTAR = @AMTAR@
+ARTSCCONFIG = @ARTSCCONFIG@
+AS = @AS@
+AUTODIRS = @AUTODIRS@
+AWK = @AWK@
+CC = @CC@
+CONF_FILES = @CONF_FILES@
+CPP = @CPP@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+DCOPIDL = @DCOPIDL@
+DCOPIDL2CPP = @DCOPIDL2CPP@
+DCOP_DEPENDENCIES = @DCOP_DEPENDENCIES@
+DEPDIR = @DEPDIR@
+DLLTOOL = @DLLTOOL@
+DPMSINC = @DPMSINC@
+DPMSLIB = @DPMSLIB@
+EXEEXT = @EXEEXT@
+GCJ = @GCJ@
+GCJFLAGS = @GCJFLAGS@
+GLINC = @GLINC@
+GLLIB = @GLLIB@
+GMSGFMT = @GMSGFMT@
+IDL = @IDL@
+IDL_DEPENDENCIES = @IDL_DEPENDENCIES@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+JAR = @JAR@
+JAVAC = @JAVAC@
+JAVAH = @JAVAH@
+JVMLIBS = @JVMLIBS@
+KDECONFIG = @KDECONFIG@
+KDE_CXXFLAGS = @KDE_CXXFLAGS@
+KDE_EXTRA_RPATH = @KDE_EXTRA_RPATH@
+KDE_INCLUDES = @KDE_INCLUDES@
+KDE_LDFLAGS = @KDE_LDFLAGS@
+KDE_PLUGIN = @KDE_PLUGIN@
+KDE_RPATH = @KDE_RPATH@
+KDE_USE_CLOSURE_FALSE = @KDE_USE_CLOSURE_FALSE@
+KDE_USE_CLOSURE_TRUE = @KDE_USE_CLOSURE_TRUE@
+KDE_USE_FINAL_FALSE = @KDE_USE_FINAL_FALSE@
+KDE_USE_FINAL_TRUE = @KDE_USE_FINAL_TRUE@
+KDE_XSL_STYLESHEET = @KDE_XSL_STYLESHEET@
+LIBCOMPAT = @LIBCOMPAT@
+LIBCRYPT = @LIBCRYPT@
+LIBDL = @LIBDL@
+LIBGEN = @LIBGEN@
+LIBJPEG = @LIBJPEG@
+LIBMICO = @LIBMICO@
+LIBOBJS = @LIBOBJS@
+LIBPNG = @LIBPNG@
+LIBPTHREAD = @LIBPTHREAD@
+LIBPYTHON = @LIBPYTHON@
+LIBQIMGIO = @LIBQIMGIO@
+LIBRESOLV = @LIBRESOLV@
+LIBSHADOW = @LIBSHADOW@
+LIBSM = @LIBSM@
+LIBSOCKET = @LIBSOCKET@
+LIBTIFF = @LIBTIFF@
+LIBTOOL = @LIBTOOL@
+LIBUCB = @LIBUCB@
+LIBUTIL = @LIBUTIL@
+LIBXINERAMA = @LIBXINERAMA@
+LIBZ = @LIBZ@
+LIB_KAB = @LIB_KAB@
+LIB_KDECORE = @LIB_KDECORE@
+LIB_KDEUI = @LIB_KDEUI@
+LIB_KFILE = @LIB_KFILE@
+LIB_KFM = @LIB_KFM@
+LIB_KFORMULA = @LIB_KFORMULA@
+LIB_KHTML = @LIB_KHTML@
+LIB_KIMGIO = @LIB_KIMGIO@
+LIB_KIO = @LIB_KIO@
+LIB_KPARTS = @LIB_KPARTS@
+LIB_KSPELL = @LIB_KSPELL@
+LIB_KSYCOCA = @LIB_KSYCOCA@
+LIB_KWRITE = @LIB_KWRITE@
+LIB_QT = @LIB_QT@
+LIB_SMB = @LIB_SMB@
+LIB_X11 = @LIB_X11@
+LN_S = @LN_S@
+MCOPIDL = @MCOPIDL@
+MEINPROC = @MEINPROC@
+MICO_INCLUDES = @MICO_INCLUDES@
+MICO_LDFLAGS = @MICO_LDFLAGS@
+MOC = @MOC@
+MSGFMT = @MSGFMT@
+NOOPT_CXXFLAGS = @NOOPT_CXXFLAGS@
+NOREPO = @NOREPO@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+PACKAGE = @PACKAGE@
+PAMLIBS = @PAMLIBS@
+PASSWDLIBS = @PASSWDLIBS@
+PYTHONINC = @PYTHONINC@
+PYTHONLIB = @PYTHONLIB@
+PYTHONMODDIR = @PYTHONMODDIR@
+QT_INCLUDES = @QT_INCLUDES@
+QT_LDFLAGS = @QT_LDFLAGS@
+RANLIB = @RANLIB@
+REPO = @REPO@
+SETUIDFLAGS = @SETUIDFLAGS@
+STRIP = @STRIP@
+TOPSUBDIRS = @TOPSUBDIRS@
+UIC = @UIC@
+UIC_TR = @UIC_TR@
+USER_INCLUDES = @USER_INCLUDES@
+USER_LDFLAGS = @USER_LDFLAGS@
+USE_EXCEPTIONS = @USE_EXCEPTIONS@
+USE_RTTI = @USE_RTTI@
+USE_THREADS = @USE_THREADS@
+VERSION = @VERSION@
+XGETTEXT = @XGETTEXT@
+XPMINC = @XPMINC@
+XPMLIB = @XPMLIB@
+X_EXTRA_LIBS = @X_EXTRA_LIBS@
+X_INCLUDES = @X_INCLUDES@
+X_LDFLAGS = @X_LDFLAGS@
+X_PRE_LIBS = @X_PRE_LIBS@
+all_includes = @all_includes@
+all_libraries = @all_libraries@
+am__include = @am__include@
+am__quote = @am__quote@
+idldir = @idldir@
+install_sh = @install_sh@
+jni_includes = @jni_includes@
+kde_appsdir = @kde_appsdir@
+kde_bindir = @kde_bindir@
+kde_confdir = @kde_confdir@
+kde_datadir = @kde_datadir@
+kde_htmldir = @kde_htmldir@
+kde_icondir = @kde_icondir@
+kde_includes = @kde_includes@
+kde_libraries = @kde_libraries@
+kde_libs_htmldir = @kde_libs_htmldir@
+kde_libs_prefix = @kde_libs_prefix@
+kde_locale = @kde_locale@
+kde_mimedir = @kde_mimedir@
+kde_moduledir = @kde_moduledir@
+kde_qtver = @kde_qtver@
+kde_servicesdir = @kde_servicesdir@
+kde_servicetypesdir = @kde_servicetypesdir@
+kde_sounddir = @kde_sounddir@
+kde_templatesdir = @kde_templatesdir@
+kde_wallpaperdir = @kde_wallpaperdir@
+micodir = @micodir@
+qt_includes = @qt_includes@
+qt_libraries = @qt_libraries@
+x_includes = @x_includes@
+x_libraries = @x_libraries@
+
+EXTRA_DIST = $(wildcard *.cc) $(wildcard *.CC)
+docs_DATA = $(EXTRA_DIST)
+
+docsdir = $(kde_htmldir)/en/kdevelop/$(subdir)
+subdir = reference/CPLUSPLUS/EXAMPLES
+mkinstalldirs = $(SHELL) $(top_srcdir)/admin/mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+DIST_SOURCES =
+DATA = $(docs_DATA)
+
+DIST_COMMON = Makefile.am Makefile.in
+#>- all: all-am
+#>+ 1
+all: docs-am all-am
+
+.SUFFIXES:
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+distclean-libtool:
+ -rm -f libtool
+$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
+#>- cd $(top_srcdir) && \
+#>- $(AUTOMAKE) --gnu reference/CPLUSPLUS/EXAMPLES/Makefile
+#>+ 3
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --gnu reference/CPLUSPLUS/EXAMPLES/Makefile
+ cd $(top_srcdir) && perl admin/am_edit reference/CPLUSPLUS/EXAMPLES/Makefile.in
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ cd $(top_builddir) && \
+ CONFIG_HEADERS= CONFIG_LINKS= \
+ CONFIG_FILES=$(subdir)/$@ $(SHELL) ./config.status
+uninstall-info-am:
+install-docsDATA: $(docs_DATA)
+ @$(NORMAL_INSTALL)
+ $(mkinstalldirs) $(DESTDIR)$(docsdir)
+ @list='$(docs_DATA)'; for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ f="`echo $$p | sed -e 's|^.*/||'`"; \
+ echo " $(INSTALL_DATA) $$d$$p $(DESTDIR)$(docsdir)/$$f"; \
+ $(INSTALL_DATA) $$d$$p $(DESTDIR)$(docsdir)/$$f; \
+ done
+
+uninstall-docsDATA:
+ @$(NORMAL_UNINSTALL)
+ @list='$(docs_DATA)'; for p in $$list; do \
+ f="`echo $$p | sed -e 's|^.*/||'`"; \
+ echo " rm -f $(DESTDIR)$(docsdir)/$$f"; \
+ rm -f $(DESTDIR)$(docsdir)/$$f; \
+ done
+tags: TAGS
+TAGS:
+
+
+#>- DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+#>+ 4
+KDE_DIST=refvar.cc enum1.c scope.cc struct1.cc inherit.cc inline.cc class1.cc cast.cc io1.cc overload.cc const1.cc throw.cc mjl_test.cc new.cc class2.cc MGREP.CC enum1.cc io2.cc
+
+DISTFILES= $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) $(KDE_DIST)
+
+
+top_distdir = ../../..
+distdir = $(top_distdir)/$(PACKAGE)-$(VERSION)
+
+distdir: $(DISTFILES)
+ @for file in $(DISTFILES); do \
+ if test -f $$file; then d=.; else d=$(srcdir); fi; \
+ dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test "$$dir" != "$$file" && test "$$dir" != "."; then \
+ $(mkinstalldirs) "$(distdir)/$$dir"; \
+ fi; \
+ if test -d $$d/$$file; then \
+ cp -pR $$d/$$file $(distdir) \
+ || exit 1; \
+ else \
+ test -f $(distdir)/$$file \
+ || cp -p $$d/$$file $(distdir)/$$file \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(DATA)
+
+installdirs:
+ $(mkinstalldirs) $(DESTDIR)$(docsdir)
+
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -rm -f Makefile $(CONFIG_CLEAN_FILES) stamp-h stamp-h[0-9]*
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+#>- clean: clean-am
+#>+ 1
+clean: kde-rpo-clean clean-am
+
+clean-am: clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-am
+
+distclean-am: clean-am distclean-generic distclean-libtool
+
+dvi: dvi-am
+
+dvi-am:
+
+info: info-am
+
+info-am:
+
+install-data-am: install-docsDATA
+
+install-exec-am:
+
+install-info: install-info-am
+
+install-man:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+
+uninstall-am: uninstall-docsDATA uninstall-info-am
+
+.PHONY: all all-am check check-am clean clean-generic clean-libtool \
+ distclean distclean-generic distclean-libtool distdir dvi \
+ dvi-am info info-am install install-am install-data \
+ install-data-am install-docsDATA install-exec install-exec-am \
+ install-info install-info-am install-man install-strip \
+ installcheck installcheck-am installdirs maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-generic \
+ mostlyclean-libtool uninstall uninstall-am uninstall-docsDATA \
+ uninstall-info-am
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
+
+#>+ 2
+docs-am:
+
+#>+ 6
+force-reedit:
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --gnu reference/CPLUSPLUS/EXAMPLES/Makefile
+ cd $(top_srcdir) && perl admin/am_edit reference/CPLUSPLUS/EXAMPLES/Makefile.in
+
+
+#>+ 2
+final:
+ $(MAKE) all-am
+#>+ 2
+final-install:
+ $(MAKE) install-am
+#>+ 2
+no-final:
+ $(MAKE) all-am
+#>+ 2
+no-final-install:
+ $(MAKE) install-am
+#>+ 3
+cvs-clean:
+ $(MAKE) -f $(top_srcdir)/admin/Makefile.common cvs-clean
+
+#>+ 3
+kde-rpo-clean:
+ -rm -f *.rpo
diff --git a/reference/CPLUSPLUS/EXAMPLES/cast.cc b/reference/CPLUSPLUS/EXAMPLES/cast.cc
new file mode 100644
index 0000000..4f4f06d
--- /dev/null
+++ b/reference/CPLUSPLUS/EXAMPLES/cast.cc
@@ -0,0 +1,18 @@
+/************************************************************************
+ *
+ * Purpose:
+ * Author: M J Leslie
+ * Date: 26-Oct-98
+ *
+ ************************************************************************/
+
+main()
+{
+ int var1;
+ float var2;
+
+ var2 = float(var1);
+
+ return 0;
+}
+
diff --git a/reference/CPLUSPLUS/EXAMPLES/class1.cc b/reference/CPLUSPLUS/EXAMPLES/class1.cc
new file mode 100644
index 0000000..d0bfb8e
--- /dev/null
+++ b/reference/CPLUSPLUS/EXAMPLES/class1.cc
@@ -0,0 +1,39 @@
+/************************************************************************
+ *
+ * Purpose: First example of the class statement.
+ * Author: M J Leslie
+ * Date: 26-Oct-98
+ *
+ ************************************************************************/
+
+
+#include <stdlib.h>
+#include <iostream.h> // Instead of stdio.h
+
+class String
+{
+public:
+
+ void Set(char *InputStr) // Declare an Access function
+ {
+ strcpy(Str, InputStr);
+ }
+
+ char *Get(void) // Declare an Access function
+ {
+ return(Str);
+ }
+
+ private:
+
+ char Str[80]; // Declare a hidden variable.
+};
+
+main()
+{
+ String Title;
+
+ Title.Set("My First Masterpiece.");
+
+ cout << Title.Get() << endl;
+}
diff --git a/reference/CPLUSPLUS/EXAMPLES/class2.cc b/reference/CPLUSPLUS/EXAMPLES/class2.cc
new file mode 100644
index 0000000..26b7c3f
--- /dev/null
+++ b/reference/CPLUSPLUS/EXAMPLES/class2.cc
@@ -0,0 +1,53 @@
+/************************************************************************
+ *
+ * Purpose:
+ * Author: M J Leslie
+ * Date: 26-Oct-98
+ *
+ ************************************************************************/
+
+
+#include <stdlib.h>
+#include <iostream.h> // Instead of stdio.h
+
+class string
+{
+ public:
+
+ // Constructor.
+
+ string()
+ {
+ Age=35;
+ }
+
+ // Destructors (Clear storage - free()).
+
+ ~String()
+ {}
+
+ // ... Overloaded functions.
+
+ void print()
+ {
+ cout << "Martin is " << Age << endl ;
+ }
+
+ void print(char * str)
+ {
+ cout << "** " << str << " **\n";
+ }
+
+ private:
+
+ int Age; // Declare Age
+
+};
+
+main()
+{
+ string test; // Constructor inserted by the compiler here.
+
+ test.print();
+ test.print("Leslie");
+}
diff --git a/reference/CPLUSPLUS/EXAMPLES/const1.cc b/reference/CPLUSPLUS/EXAMPLES/const1.cc
new file mode 100644
index 0000000..67fa74d
--- /dev/null
+++ b/reference/CPLUSPLUS/EXAMPLES/const1.cc
@@ -0,0 +1,46 @@
+
+/**************************************************************************
+ *
+ * Language: C++
+ * Purpose: Program to demonstrate the 'new' statement.
+ * Author: M J Leslie
+ * Date: 27-Sep-98
+ *
+ * Initialise a constant within a class.
+ *
+ **************************************************************************/
+
+#include <iostream.h> // For cout.
+
+class Math
+{
+public:
+
+ // Constructor contains the definition of PI.
+
+ Math() : PI(3.142) {}
+
+ ~Math() {}
+
+ float Diameter (float Radius)
+ {
+ return (Radius * PI);
+ }
+
+private:
+
+ // Declare PI. We can not assign a value here.
+
+ const float PI;
+
+};
+
+main()
+{
+ Math Formula;
+ float Radius = 5;
+
+ cout << " Radius is " << Radius << endl;
+ cout << " Diameter is " << Formula.Diameter(Radius) << endl;
+}
+
diff --git a/reference/CPLUSPLUS/EXAMPLES/enum1.c b/reference/CPLUSPLUS/EXAMPLES/enum1.c
new file mode 100644
index 0000000..6409eb2
--- /dev/null
+++ b/reference/CPLUSPLUS/EXAMPLES/enum1.c
@@ -0,0 +1,23 @@
+/************************************************************************
+ *
+ * Purpose:
+ * Author: M J Leslie
+ * Date: 26-Oct-98
+ *
+ ************************************************************************/
+
+
+// #include <iostream.h>
+
+main()
+{
+ enum Colour { Red=1, Amber, Green};
+
+ Colour TraficLight;
+
+
+ TraficLight++;
+
+ return 0;
+}
+
diff --git a/reference/CPLUSPLUS/EXAMPLES/enum1.cc b/reference/CPLUSPLUS/EXAMPLES/enum1.cc
new file mode 100644
index 0000000..7c77204
--- /dev/null
+++ b/reference/CPLUSPLUS/EXAMPLES/enum1.cc
@@ -0,0 +1,23 @@
+/************************************************************************
+ *
+ * Purpose:
+ * Author: M J Leslie
+ * Date: 26-Oct-98
+ *
+ ************************************************************************/
+
+
+#include <iostream.h>
+
+main()
+{
+ enum Colour { Red=1, Amber, Green};
+
+ Colour TraficLight++;
+
+
+ TraficLight++;
+
+ return 0;
+}
+
diff --git a/reference/CPLUSPLUS/EXAMPLES/inherit.cc b/reference/CPLUSPLUS/EXAMPLES/inherit.cc
new file mode 100644
index 0000000..47365f9
--- /dev/null
+++ b/reference/CPLUSPLUS/EXAMPLES/inherit.cc
@@ -0,0 +1,116 @@
+/************************************************************************
+ *
+ * Purpose:
+ * Author: M J Leslie
+ * Date: 26-Oct-98
+ *
+ ************************************************************************/
+
+
+#include <stdlib.h>
+#include <iostream.h> // Instead of stdio.h
+
+
+// ... The base class 'Fabric'
+// ... is no different to normal.
+
+
+class Fabric
+{
+public:
+
+ Fabric() {};
+ ~Fabric(){};
+
+ SetSize(int x, int y)
+ {
+ Length = x;
+ Width = y;
+ }
+
+ SetColour(char *C)
+ {
+ strcpy(Colour, C);
+ }
+
+private:
+ int Length;
+ int Width;
+ char Colour[20];
+};
+
+
+
+// ... The derived class 'Tent'
+// ... names 'Fabric' as a base class.
+
+
+class Tent : public Fabric
+{
+public:
+
+ Tent() {};
+ ~Tent() {};
+
+ SetNumOfPoles(int P)
+ {
+ Poles = P;
+ }
+
+private:
+ int Poles;
+};
+
+
+// ... The derived class 'Clothes' also
+// ... names 'Fabric' as a base class.
+
+
+class Clothes : public Fabric
+{
+ public:
+
+ Clothes() {};
+ ~Clothes() {};
+
+ void SetNumOfButtons(int B)
+ {
+ Buttons = B;
+ };
+
+ int GetNumOfButtons(void)
+ {
+ return (Buttons);
+ };
+
+ private:
+ int Buttons;
+};
+
+
+// ... Function definitions.
+
+void Init(Fabric &Material);
+
+main()
+{
+ Tent Frame;
+ Clothes Jacket;
+
+ // ... Initialise using the derived methods.
+
+ Init(Frame);
+ Init(Jacket);
+
+ // .. Initialise using the unique methods.
+
+ Frame.SetNumOfPoles(5);
+ Jacket.SetNumOfButtons(2);
+
+}
+
+void Init(Fabric &Material)
+{
+ Material.SetColour("Red");
+ Material.SetSize (10, 20);
+}
diff --git a/reference/CPLUSPLUS/EXAMPLES/inline.cc b/reference/CPLUSPLUS/EXAMPLES/inline.cc
new file mode 100644
index 0000000..2d0424b
--- /dev/null
+++ b/reference/CPLUSPLUS/EXAMPLES/inline.cc
@@ -0,0 +1,15 @@
+
+/**************************************************************************
+ *
+ * Language: C++
+ * Purpose: Program to demonstrate the 'inline' statement.
+ * Author: M J Leslie
+ * Date: 14-Feb-96
+ * Descrip: To be written.
+ *
+ **************************************************************************/
+
+main()
+{
+}
+
diff --git a/reference/CPLUSPLUS/EXAMPLES/io1.cc b/reference/CPLUSPLUS/EXAMPLES/io1.cc
new file mode 100644
index 0000000..22f22dc
--- /dev/null
+++ b/reference/CPLUSPLUS/EXAMPLES/io1.cc
@@ -0,0 +1,19 @@
+/************************************************************************
+ *
+ * Purpose:
+ * Author: M J Leslie
+ * Date: 26-Oct-98
+ *
+ ************************************************************************/
+
+
+#include <iostream.h> // cout, cin
+
+main()
+{
+ char buf[255];
+
+ cout << "Please enter a string ==> "; // O/P to STDOUT (screen).
+ cin >> buf; // I/P from STDIN (keyboard).
+ cout << "Entered string is " << buf << endl;
+}
diff --git a/reference/CPLUSPLUS/EXAMPLES/io2.cc b/reference/CPLUSPLUS/EXAMPLES/io2.cc
new file mode 100644
index 0000000..53484a7
--- /dev/null
+++ b/reference/CPLUSPLUS/EXAMPLES/io2.cc
@@ -0,0 +1,27 @@
+/************************************************************************
+ *
+ * Purpose:
+ * Author: M J Leslie
+ * Date: 26-Oct-98
+ *
+ ************************************************************************/
+
+
+#include <fstream.h> // ifstream, ofstream, fstream
+#include <iostream.h> // cin, cout
+
+main()
+{
+ char buf[255];
+ char File[]="tempfile";
+
+ cout << "Please enter a string => "; // O/P to STDOUT (screen).
+ cin >> buf; // Read from STDIN (keyboard).
+
+ cout << " Writing string to " << File << "\n";
+
+ ofstream fp(File); // Open file for O/P
+ fp << buf << "\n"; // Write to the file.
+
+ // ... File is closed at program end.
+}
diff --git a/reference/CPLUSPLUS/EXAMPLES/mjl_test.cc b/reference/CPLUSPLUS/EXAMPLES/mjl_test.cc
new file mode 100644
index 0000000..cd8a720
--- /dev/null
+++ b/reference/CPLUSPLUS/EXAMPLES/mjl_test.cc
@@ -0,0 +1,27 @@
+
+ #include <iostream.h>
+
+ void Add(int Left, int Right);
+ void Add(double Left, double Right);
+
+ main ()
+ {
+
+ Add(5, 9);
+ Add(3.2, 7.1);
+ }
+
+ // integer version of Add.
+
+ void Add(int Left, int Right)
+ {
+ cout << Left << " + " << Right << " = " << Left+Right << endl;
+ }
+
+ // float version of Add.
+
+ void Add(double Left, double Right)
+ {
+ cout << Left << " + " << Right << " = " << Left+Right << endl;
+ }
+
diff --git a/reference/CPLUSPLUS/EXAMPLES/new.cc b/reference/CPLUSPLUS/EXAMPLES/new.cc
new file mode 100644
index 0000000..6373e55
--- /dev/null
+++ b/reference/CPLUSPLUS/EXAMPLES/new.cc
@@ -0,0 +1,39 @@
+
+/**************************************************************************
+ *
+ * Language: C++
+ * Purpose: Program to demonstrate the 'new' statement.
+ * Author: M J Leslie
+ * Date: 14-Feb-96
+ *
+ **************************************************************************/
+
+#include <iostream.h> // For cout.
+
+typedef struct
+ {
+ char Model[256];
+ int Wheels;
+ int Doors;
+ int EngineSize;
+ } Car_t;
+
+main()
+{
+ Car_t *Models; // Create a pointer.
+
+ Models = new Car_t; // Allocate stoarage.
+
+ // Load with data.
+ strcpy(Models->Model, "Escort");
+ Models->Wheels = 4;
+ Models->Doors = 3;
+ Models->EngineSize = 1499;
+
+ // Display data.
+
+ cout << Models->Model << " has " << Models->Doors << "doors" << endl;
+
+ delete Models; // Free the storage.
+}
+
diff --git a/reference/CPLUSPLUS/EXAMPLES/overload.cc b/reference/CPLUSPLUS/EXAMPLES/overload.cc
new file mode 100644
index 0000000..cd8a720
--- /dev/null
+++ b/reference/CPLUSPLUS/EXAMPLES/overload.cc
@@ -0,0 +1,27 @@
+
+ #include <iostream.h>
+
+ void Add(int Left, int Right);
+ void Add(double Left, double Right);
+
+ main ()
+ {
+
+ Add(5, 9);
+ Add(3.2, 7.1);
+ }
+
+ // integer version of Add.
+
+ void Add(int Left, int Right)
+ {
+ cout << Left << " + " << Right << " = " << Left+Right << endl;
+ }
+
+ // float version of Add.
+
+ void Add(double Left, double Right)
+ {
+ cout << Left << " + " << Right << " = " << Left+Right << endl;
+ }
+
diff --git a/reference/CPLUSPLUS/EXAMPLES/refvar.cc b/reference/CPLUSPLUS/EXAMPLES/refvar.cc
new file mode 100644
index 0000000..1e8ddd5
--- /dev/null
+++ b/reference/CPLUSPLUS/EXAMPLES/refvar.cc
@@ -0,0 +1,26 @@
+/************************************************************************
+ *
+ * Purpose: Demonstrate the use of reference variables.
+ * Author: M J Leslie
+ * Date: 26-Oct-98
+ *
+ ************************************************************************/
+
+
+#include <stdio.h>
+
+int Square(int &Val);
+
+main()
+{
+ int Number=10;
+
+ Square(Number);
+
+ printf("Number is %d\n", Number);
+}
+
+int Square(int &Val)
+{
+ Val *= Val;
+}
diff --git a/reference/CPLUSPLUS/EXAMPLES/scope.cc b/reference/CPLUSPLUS/EXAMPLES/scope.cc
new file mode 100644
index 0000000..a246ba6
--- /dev/null
+++ b/reference/CPLUSPLUS/EXAMPLES/scope.cc
@@ -0,0 +1,27 @@
+/************************************************************************
+ *
+ * Purpose:
+ * Author: M J Leslie
+ * Date: 26-Oct-98
+ *
+ ************************************************************************/
+
+
+#include <iostream.h> // cout, cin
+
+int Counter = 1;
+
+main()
+{
+
+ int Counter = 1;
+
+ for (int i=0; i< 10; i++)
+ {
+ cout << Counter << " " << ::Counter << endl;
+ Counter++;
+ }
+
+ return 0;
+}
+
diff --git a/reference/CPLUSPLUS/EXAMPLES/struct1.cc b/reference/CPLUSPLUS/EXAMPLES/struct1.cc
new file mode 100644
index 0000000..9fa884a
--- /dev/null
+++ b/reference/CPLUSPLUS/EXAMPLES/struct1.cc
@@ -0,0 +1,53 @@
+/******************************************************************
+ *
+ * Purpose: Program to demonstrate struct in C++.
+ * Date: 04-Aug-97
+ * Author: M J Leslie.
+ * Descrip:
+ *
+ ******************************************************************/
+
+#include <stdio.h> // printf
+
+struct Person
+{
+ // ... Declare the variables in the 'Person' structure.
+ // ... This is normal C syntax.
+
+ char Name[35];
+ int Age;
+
+ // ... Declare a function within the structure. This is
+ // ... new to C++
+
+ int YearsToRetire(void) // \
+ { // --- Function in a structure.
+ return 65-Age; // ---
+ } // /
+};
+
+// ... Program to test the 'Person' structure.
+
+int main(int argc, char **argc )
+{
+ // ... Create a person called Mr Leslie.
+
+ Person Mr_Leslie;
+
+ // ... Put some data into the structure.
+
+ strcpy(Mr_Leslie.Name, "Martin");
+
+ Mr_Leslie.Age=36;
+
+ // ... Extract data from the structure.
+ // ... Use the 'YearsToRetire' function to
+ // ... Calculate the number of years this poor
+ // ... soul has to work before retirement.
+
+ printf("%s will retire in %d years\n",
+ Mr_Leslie.Name,
+ Mr_Leslie.YearsToRetire()); // <-- Call the function.
+
+ return (0);
+}
diff --git a/reference/CPLUSPLUS/EXAMPLES/throw.cc b/reference/CPLUSPLUS/EXAMPLES/throw.cc
new file mode 100644
index 0000000..ca86673
--- /dev/null
+++ b/reference/CPLUSPLUS/EXAMPLES/throw.cc
@@ -0,0 +1,43 @@
+
+/**************************************************************************
+ *
+ * Language: C++
+ * Purpose: Program to demonstrate the 'try', 'catch' and 'throw' statements.
+ * Author: M J Leslie
+ * Date: 21-Mar-98
+ *
+ * Compile: The following command was used to compile.
+ *
+ * g++ -fhandle-exceptions throw.cc -o throw
+ *
+ **************************************************************************/
+
+#include <iostream.h> // For cout.
+
+void ErrorFunc(int Error);
+
+main()
+{
+ ErrorFunc(0);
+ ErrorFunc(1);
+}
+void ErrorFunc(int Error)
+{
+ try
+ {
+ cout << "Error code is " << Error << endl;
+
+ if (Error > 0 )
+ {
+ throw(Error); // This statement causes control to jump
+ // to the 'catch' statement
+ }
+
+ cout << "No Error occoured" << endl;
+
+ }
+ catch(int n)
+ {
+ cout << "Error number is " << n << endl;;
+ }
+}