From 7e0f021a9aec35fd8e6725e87e3313b101d26f5e Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Sun, 27 Jan 2008 11:37:44 +0100 Subject: Initial import (2.0.2-6) --- reference/CPLUSPLUS/CONCEPT/Makefile.am | 5 + reference/CPLUSPLUS/CONCEPT/Makefile.in | 410 +++++++++++++++++++++ reference/CPLUSPLUS/CONCEPT/Master.html | 60 +++ reference/CPLUSPLUS/CONCEPT/cast.html | 89 +++++ reference/CPLUSPLUS/CONCEPT/constructor.html | 78 ++++ reference/CPLUSPLUS/CONCEPT/funcoverload.html | 153 ++++++++ reference/CPLUSPLUS/CONCEPT/fundefault.html | 115 ++++++ reference/CPLUSPLUS/CONCEPT/inheritance.html | 264 +++++++++++++ reference/CPLUSPLUS/CONCEPT/local_var.html | 144 ++++++++ .../CPLUSPLUS/CONCEPT/reference_variable.html | 167 +++++++++ reference/CPLUSPLUS/CONCEPT/scope.html | 100 +++++ 11 files changed, 1585 insertions(+) create mode 100644 reference/CPLUSPLUS/CONCEPT/Makefile.am create mode 100644 reference/CPLUSPLUS/CONCEPT/Makefile.in create mode 100644 reference/CPLUSPLUS/CONCEPT/Master.html create mode 100644 reference/CPLUSPLUS/CONCEPT/cast.html create mode 100644 reference/CPLUSPLUS/CONCEPT/constructor.html create mode 100644 reference/CPLUSPLUS/CONCEPT/funcoverload.html create mode 100644 reference/CPLUSPLUS/CONCEPT/fundefault.html create mode 100644 reference/CPLUSPLUS/CONCEPT/inheritance.html create mode 100644 reference/CPLUSPLUS/CONCEPT/local_var.html create mode 100644 reference/CPLUSPLUS/CONCEPT/reference_variable.html create mode 100644 reference/CPLUSPLUS/CONCEPT/scope.html (limited to 'reference/CPLUSPLUS/CONCEPT') diff --git a/reference/CPLUSPLUS/CONCEPT/Makefile.am b/reference/CPLUSPLUS/CONCEPT/Makefile.am new file mode 100644 index 0000000..5baa6fe --- /dev/null +++ b/reference/CPLUSPLUS/CONCEPT/Makefile.am @@ -0,0 +1,5 @@ +EXTRA_DIST = $(wildcard *.html) $(wildcard *.gif) +docs_DATA = $(EXTRA_DIST) + +docsdir = $(kde_htmldir)/en/kdevelop/$(subdir) + diff --git a/reference/CPLUSPLUS/CONCEPT/Makefile.in b/reference/CPLUSPLUS/CONCEPT/Makefile.in new file mode 100644 index 0000000..6ec8bd7 --- /dev/null +++ b/reference/CPLUSPLUS/CONCEPT/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 *.html) $(wildcard *.gif) +docs_DATA = $(EXTRA_DIST) + +docsdir = $(kde_htmldir)/en/kdevelop/$(subdir) +subdir = reference/CPLUSPLUS/CONCEPT +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/CONCEPT/Makefile +#>+ 3 + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu reference/CPLUSPLUS/CONCEPT/Makefile + cd $(top_srcdir) && perl admin/am_edit reference/CPLUSPLUS/CONCEPT/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=constructor.html inheritance.html cast.html scope.html funcoverload.html Master.html local_var.html reference_variable.html fundefault.html + +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/CONCEPT/Makefile + cd $(top_srcdir) && perl admin/am_edit reference/CPLUSPLUS/CONCEPT/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/CONCEPT/Master.html b/reference/CPLUSPLUS/CONCEPT/Master.html new file mode 100644 index 0000000..5eca2c7 --- /dev/null +++ b/reference/CPLUSPLUS/CONCEPT/Master.html @@ -0,0 +1,60 @@ + + +Title here + + + +
+

Title here.

+
+

+ +


+

Examples:

+o +Example program. +

+ +


+

See Also:

+ +
+
+ +

C References

+

+o +data types. + + + +


+

+

+ + + + +
+Top + +Master Index + +Keywords + +Functions +
+
+

+


+ +
Martin Leslie + +

+ + + diff --git a/reference/CPLUSPLUS/CONCEPT/cast.html b/reference/CPLUSPLUS/CONCEPT/cast.html new file mode 100644 index 0000000..cc2df6e --- /dev/null +++ b/reference/CPLUSPLUS/CONCEPT/cast.html @@ -0,0 +1,89 @@ + + +C++ casting + + + +


+

C++ casting.

+
+

+ +C++ has added a new feature to +cast +that allows you to cast variables by using a slightly +more familuar syntax. Have a look at the example below. + +

+

+ + + + +
+
+        
+    main()
+    {
+        int var1;
+        float var2;
+
+        var2 = float(var1);
+    }
+
+
+
+

+The example shows that casting can now look like a function call. +

+


+

Examples:

+ + +o +C++ Example program. + + +
+

See Also:

+ +
+
+ +

C References

+

+o +C casting. + + + +


+

+

+ + + + +
+Top + +Master Index + +Keywords + +Functions +
+
+

+


+ +
Martin Leslie + +

+ + + diff --git a/reference/CPLUSPLUS/CONCEPT/constructor.html b/reference/CPLUSPLUS/CONCEPT/constructor.html new file mode 100644 index 0000000..29b3cc4 --- /dev/null +++ b/reference/CPLUSPLUS/CONCEPT/constructor.html @@ -0,0 +1,78 @@ + + +Constructors and Destructors. + + + +


+

Constructors and Destructors.

+
+ +

Constructor

+ +The constructor is executed when an object is created. +Its purpose is to initalise variables with in an object +before they can be used. + + +
    +
  • If you do not provide a constructor for a class, the compiler + will create a default constructor for you. + +
  • If the object has global scope, the constructor is executed + before main() +
+ +
+

Copy Constructor

+ +
+

Assignment Constructor

+ +
+

Destructor

+

+ +


+

See Also:

+ +
+
+ +

C References

+

+o +data types. + + + +


+

+

+ + + + +
+Top + +Master Index + +Keywords + +Functions +
+
+

+


+ +
Martin Leslie + +

+ + + diff --git a/reference/CPLUSPLUS/CONCEPT/funcoverload.html b/reference/CPLUSPLUS/CONCEPT/funcoverload.html new file mode 100644 index 0000000..a245e32 --- /dev/null +++ b/reference/CPLUSPLUS/CONCEPT/funcoverload.html @@ -0,0 +1,153 @@ + + +Function Overloading. + + + +


+

Function Overloading.

+
+

+Overloading is a technique that allows you to give a several +functions with the same name but different parameter lists. +

+Consider the following program. +

+

+ + + + +
+
+
+    #include <iostream.h>
+    
+    void Add(int Left,   int Right);
+
+    main ()
+    {
+        Add(5, 9);              // Integer Add.
+        Add(3.2, 7.1);          // Floating point Add.
+    }
+ 
+    // Integer version of Add.
+       
+    void Add(int Left, int Right)
+    {
+        cout << Left << " + " << Right << " = " << Left+Right << endl;
+    }
+
+
+
+

+The program contains the Add function that adds integers. +But the main calls it twice, once passing integers and the second +time passing floating point numbers. The program will compile and run +but you will get incorrect results because the floats will be + cast to integers. +

+The second +program offers a solution by overloading the Add function. + +

+

+ + + + +
+
+
+    #include <iostream.h>
+    
+    void Add(int    Left, int    Right);
+    void Add(double Left, double Right);
+
+    main ()
+    {
+        Add(5, 9);             // Integer Add.        
+        Add(3.2, 7.1);         // Floating point Add. 
+    }
+ 
+    // 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;
+    }
+
+
+
+
+ +The compiler can now look at the call list and match it with +a function with the correct parameter list and the floating +point addition is performed correctly. + +

+ +Please note that the returned argument is not used when matching +overloaded functions. + + +


+

Examples:

+o +Example program. +

+ +


+

See Also:

+ +o +Default Parameter Values.. + + +
+
+ +

C References

+

+o +Function Basics. + + + +


+

+

+ + + + +
+Top + +Master Index + +Keywords + +Functions +
+
+

+


+ +
Martin Leslie + +

+ + + diff --git a/reference/CPLUSPLUS/CONCEPT/fundefault.html b/reference/CPLUSPLUS/CONCEPT/fundefault.html new file mode 100644 index 0000000..80cd0aa --- /dev/null +++ b/reference/CPLUSPLUS/CONCEPT/fundefault.html @@ -0,0 +1,115 @@ + + +Default Parameters. + + + +


+

Default Parameters.

+
+

+Within C you could not provide default values for function +parameters. Well, C++ has come to your rescue. +

+ +

+ + + + +
+
+
+    #include <iostream.h>
+    
+    void Func( int one, int two=2, int three=3);
+    
+    main ()
+    {
+        Func(10, 20, 30);
+        Func(10, 20);   // Let the last parm default
+        Func(10);       // Just provide the required parm.
+    }
+    
+
+    void Func( int one, int two, int three)
+    {
+        cout << "One   = " << one   << endl;
+        cout << "Two   = " << two   << endl;
+        cout << "Three = " << three << endl << endl;
+    }
+
+
+
+ +

+From this example, you can see that the prototype/function declaration +gives default values for the second and third parameters. It is now +down to the programmer calling the function to decide how many +s/he wants to provide. +

+There are some basic rules that should be applied when using +default parameter values. +

+

+


+

Examples:

+ + +
+

See Also:

+ +o +Function Name Overloading. +
+
+ +

C References

+

+o +Function basics. + + + +


+

+

+ + + + +
+Top + +Master Index + +Keywords + +Functions +
+
+

+


+ +
Martin Leslie + +

+ + + diff --git a/reference/CPLUSPLUS/CONCEPT/inheritance.html b/reference/CPLUSPLUS/CONCEPT/inheritance.html new file mode 100644 index 0000000..0c8822c --- /dev/null +++ b/reference/CPLUSPLUS/CONCEPT/inheritance.html @@ -0,0 +1,264 @@ + + +Inheritance + + + +


+

Inheritance.

+
+

+Inheritance enables classes to use the properties of other classes and +add to those properties. +

+The thing to remember about object programming is that it attempts to +create a software model as close to the real world as possible. Inheritance +forms an important role to meet this need. Take the following example. +

+A fabric can have a colour and size and it is also used to make clothes +as well as tents. Now looking at this from the other angle tents are made +from fabric and poles but clothes are made from fabric and buttons. +So, Tents and clothes have something in common, fabric! If we described +tents and clothes in C++, we can seperate fabric into a seperate class +that the Tent and Clothes classes can inherit. +

+

+ + + + +
+
+
+       -----------         
+      |  Fabric   |        
+       -----------         
+          A    A           
+          |    |           
+       ---      ---        
+      |            |       
+ ---------     ----------- 
+|  Tent   |   |  Clothes  |
+ ---------     ----------- 
+
+
+
+
+
+

+Now for some buzz words: +

    +
  1. Fabric is a base class +
  2. Tent and Clothes are derived classes +
+This is what the code looks like: +

+

+ + + + + +
+
+
+// ... 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.
+
+
+
+
+// ... The derived class 'Clothes' also
+// ... names 'Fabric' as a base class.
+
+
+
+
+  class Tent : public Fabric
+  {
+  public:
+
+       Tent() {};
+      ~Tent() {};
+
+      SetNumOfPoles(int P)
+      {
+          Poles = P;
+      };
+
+  private:
+      int  Poles;
+  };
+        
+
+
+
+
+  class Clothes : public Fabric
+  {
+  public:
+
+      Clothes() {};
+      ~Clothes() {};
+
+      SetNumOfButtons(int B)
+      {
+          Buttons = B;
+      };
+
+  private:
+      int  Buttons;
+  };
+        
+
+
+
+

+ +What we now have are three classes with the following public methods. + +

+ + +

Using the classes

+ +So we have three classes, they are used in the same way as before but +with one extra feature. +

+Consider this piece of code. + + +

+ + + + +
+
+  void Init(Fabric &Material);
+
+  main()
+  {
+      Tent       Frame;
+      Clothes    Jacket;
+
+      Init(Frame);
+      Init(Jacket);
+  }
+
+  void Init(Fabric &Material)
+  {
+      Material.SetColour("Red");
+      Material.SetSize  (10, 20);
+  }
+     
+
+
+
+

+ +The function 'Init' expects an object of type 'Fabric' but we +are passing objects of type 'Tents' and 'Clothes', this is OK as +'Tents' and 'Clothes' are derived from Fabric. + +

+


+

Examples:

+o +The final program. +

+ +


+

See Also:

+ + +
+

+

+ + + + +
+Top + +Master Index + +Keywords + +Functions +
+
+

+


+ +
Martin Leslie +29-Dec-97

+ + + diff --git a/reference/CPLUSPLUS/CONCEPT/local_var.html b/reference/CPLUSPLUS/CONCEPT/local_var.html new file mode 100644 index 0000000..f6cb994 --- /dev/null +++ b/reference/CPLUSPLUS/CONCEPT/local_var.html @@ -0,0 +1,144 @@ + + +C++ Local Variables. + + + +


+

C++ Local Variables.

+
+

+ +There is not much difference between + C local variables but there +is one important feature that should be noted. +

    +
  • Variable definitions are now considered to be executable statements. +
+This means that you can now put variable definitions anywhere in the code +and not jut at the start of a +block. +Here is an example. + +

+

+ + +
+
+
+    main()
+    {
+        float pi = 3.142;   // Usual location for variable definitions
+        
+        cout << "PI is " << pi << endl;
+        
+        int Count = 1;      // C++ allows us to place a definition here.
+        
+        while (Count < 10)
+        {
+            cout << Count << endl;
+        }
+    }
+
+
+
+

+ +It should be noted that Count is only in scope (usable) from the +point of definition and to the end of the block. +It can not be used in the previous cout statement. +

+ +The idea of this feature is to allow you to put variable declarations +near to the place +you wish to use them. Personnaly, I feel this should not be neccasary +if you write small concise functions.... + +There is one natty feature of this facility though. Check this +example out. +

+

+ + +
+
+
+    main()
+    {
+        int Last = 10;      
+        
+        while (int Count; Count < Last; Count++)
+        {
+            cout << Count << endl;
+        }
+    }
+
+
+
+

+In this example, Count is defined inside the for +statement and only exists while the for block is being executed. + + +

+


+

Examples:

+ + +
+

See Also:

+ +
+
+ +

C References

+

+ +o + C local variables +

+o +data types. + + + +


+

+

+ + + + +
+Top + +Master Index + +Keywords + +Functions +
+
+

+


+ +
Martin Leslie + +

+ + + diff --git a/reference/CPLUSPLUS/CONCEPT/reference_variable.html b/reference/CPLUSPLUS/CONCEPT/reference_variable.html new file mode 100644 index 0000000..f907323 --- /dev/null +++ b/reference/CPLUSPLUS/CONCEPT/reference_variable.html @@ -0,0 +1,167 @@ + + +Reference variables + + + +


+

Reference Variables.

+
+

+Reference variables allow two variable names to address the +same memory location. The following example shows the +technique in its simplest form. + +

+

+ + + + +
+
+        
+    #include 
+    
+    main()
+    {
+        int var1;
+        int &var2 = var1;       // var2 is a reference variable.
+
+        var1 = 10;
+    
+        cout << "var1 = " << var1 << endl;
+        cout << "var2 = " << var2 << endl;
+    }
+
+
+
+

+ + +Generally, you would not use a reference variable +in this way. Its more likely that they would be used +in function parameter lists to make the passing of +pointers more readable. +

+This gives C++ the ability to provide a +different approch to changing a variable from within a +function. Consider the two following programs. + +

+

+ + + + + + +
+
+
+    #include <stdio.h>
+
+    void Square(int *pVal);
+
+    main()
+    {
+        int Number=10;
+
+        printf("Number is %d\n", Number);
+
+        Square(&Number);
+
+        printf("Number is %d\n", Number);
+    }
+
+    void Square(int *pVal)
+    {
+        *pVal *= *pVal;            
+        
+        printf("Number is %d\n", *pVal);
+    }
+
+
+
+
+
+    #include <stdio.h>
+
+    void Square(int &Val);
+
+    main()
+    {
+        int Number=10;
+
+        printf("Number is %d\n", Number);
+
+        Square(Number);
+
+        printf("Number is %d\n", Number);
+    }
+
+    void Square(int &Val)
+    {
+        Val *= Val;
+        
+        printf("Number is %d\n", Val);
+    }
+
+
+
+
+

+ +The program on the right should be clearer to read +because you do not need to worry about pointer +dereferencing. + +


+

Examples:

+o +Example program. +

+ + +o +Example C program. + + +


+

See Also:

+ +
+
+ +

C References

+

+o +data types. + + + +


+

+

+ + + + +
+Top + +Master Index + +Keywords + +Functions +
+
+

+


+ +
Martin Leslie +29-Sep-96

+ + + diff --git a/reference/CPLUSPLUS/CONCEPT/scope.html b/reference/CPLUSPLUS/CONCEPT/scope.html new file mode 100644 index 0000000..74f651e --- /dev/null +++ b/reference/CPLUSPLUS/CONCEPT/scope.html @@ -0,0 +1,100 @@ + + +Scope in C++ + + + +


+

Scope in C++.

+
+

+ +The :: operator is used within C++ to identify global variables that +conflict with local variable names. Obviously it would be good programming +practice to use suitable names in the first place...... + +

+

+ + + + +
+
+
+        #include 
+        
+        int Counter = 1;
+        
+        main()     
+        {
+            int Counter = 1;
+            
+            for (int i=0; i< 10; i++)
+            {
+                cout << Counter << " " << ::Counter << endl;
+                Counter++; 
+            }
+            
+            return 0;
+        }
+
+
+
+

+ +


+

Examples:

+o +Example program. +

+ +


+

See Also:

+o +C++ operators.. + +
+
+ +

C References

+

+o +Global Variables. +

+o +C Expressions and Operators. + + + + +


+

+

+ + + + +
+Top + +Master Index + +Keywords + +Functions +
+
+

+


+ +
Martin Leslie + +

+ + + -- cgit v1.2.3-54-g00ecf