examples/before/example_classes.h
author William Roberts <williamr@symbian.org>
Mon, 26 Jul 2010 11:39:25 +0100
changeset 11 3dcb71781467
parent 5 29cf076edbda
permissions -rw-r--r--
Various tweaks to the summarising tools
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
fe474e3b08fb Created the examples directory, containing components called "before" and "after"
William Roberts <williamr@symbian.org>
parents:
diff changeset
     1
// Copyright (c) 2010 Symbian Foundation Ltd.
fe474e3b08fb Created the examples directory, containing components called "before" and "after"
William Roberts <williamr@symbian.org>
parents:
diff changeset
     2
// All rights reserved.
fe474e3b08fb Created the examples directory, containing components called "before" and "after"
William Roberts <williamr@symbian.org>
parents:
diff changeset
     3
// This component and the accompanying materials are made available
fe474e3b08fb Created the examples directory, containing components called "before" and "after"
William Roberts <williamr@symbian.org>
parents:
diff changeset
     4
// under the terms of the License "Eclipse Public License v1.0"
fe474e3b08fb Created the examples directory, containing components called "before" and "after"
William Roberts <williamr@symbian.org>
parents:
diff changeset
     5
// which accompanies this distribution, and is available
fe474e3b08fb Created the examples directory, containing components called "before" and "after"
William Roberts <williamr@symbian.org>
parents:
diff changeset
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
fe474e3b08fb Created the examples directory, containing components called "before" and "after"
William Roberts <williamr@symbian.org>
parents:
diff changeset
     7
//
fe474e3b08fb Created the examples directory, containing components called "before" and "after"
William Roberts <williamr@symbian.org>
parents:
diff changeset
     8
// Initial Contributors:
fe474e3b08fb Created the examples directory, containing components called "before" and "after"
William Roberts <williamr@symbian.org>
parents:
diff changeset
     9
// Symbian Foundation - Initial contribution
fe474e3b08fb Created the examples directory, containing components called "before" and "after"
William Roberts <williamr@symbian.org>
parents:
diff changeset
    10
// 
fe474e3b08fb Created the examples directory, containing components called "before" and "after"
William Roberts <williamr@symbian.org>
parents:
diff changeset
    11
// Description:
fe474e3b08fb Created the examples directory, containing components called "before" and "after"
William Roberts <williamr@symbian.org>
parents:
diff changeset
    12
// Examples of things which GCC does not like in the Symbian codebase.
fe474e3b08fb Created the examples directory, containing components called "before" and "after"
William Roberts <williamr@symbian.org>
parents:
diff changeset
    13
fe474e3b08fb Created the examples directory, containing components called "before" and "after"
William Roberts <williamr@symbian.org>
parents:
diff changeset
    14
// Various problems with classes
fe474e3b08fb Created the examples directory, containing components called "before" and "after"
William Roberts <williamr@symbian.org>
parents:
diff changeset
    15
fe474e3b08fb Created the examples directory, containing components called "before" and "after"
William Roberts <williamr@symbian.org>
parents:
diff changeset
    16
class TClass1
fe474e3b08fb Created the examples directory, containing components called "before" and "after"
William Roberts <williamr@symbian.org>
parents:
diff changeset
    17
	{
fe474e3b08fb Created the examples directory, containing components called "before" and "after"
William Roberts <williamr@symbian.org>
parents:
diff changeset
    18
	public:
fe474e3b08fb Created the examples directory, containing components called "before" and "after"
William Roberts <williamr@symbian.org>
parents:
diff changeset
    19
	TClass1(int a, int b);
fe474e3b08fb Created the examples directory, containing components called "before" and "after"
William Roberts <williamr@symbian.org>
parents:
diff changeset
    20
	int TClass1::Average();			// Error! Member function name should not be qualified
fe474e3b08fb Created the examples directory, containing components called "before" and "after"
William Roberts <williamr@symbian.org>
parents:
diff changeset
    21
	
fe474e3b08fb Created the examples directory, containing components called "before" and "after"
William Roberts <williamr@symbian.org>
parents:
diff changeset
    22
	private:
fe474e3b08fb Created the examples directory, containing components called "before" and "after"
William Roberts <williamr@symbian.org>
parents:
diff changeset
    23
	int iA;
fe474e3b08fb Created the examples directory, containing components called "before" and "after"
William Roberts <williamr@symbian.org>
parents:
diff changeset
    24
	int iB;
fe474e3b08fb Created the examples directory, containing components called "before" and "after"
William Roberts <williamr@symbian.org>
parents:
diff changeset
    25
	};
5
29cf076edbda Extending examples for some more good code bad code.
arunabha
parents: 0
diff changeset
    26
29cf076edbda Extending examples for some more good code bad code.
arunabha
parents: 0
diff changeset
    27
29cf076edbda Extending examples for some more good code bad code.
arunabha
parents: 0
diff changeset
    28
// Correct refenrencing of types defined inside a class Template
29cf076edbda Extending examples for some more good code bad code.
arunabha
parents: 0
diff changeset
    29
// Symptom GCC : Error: Expected initializer before ' (class name)' 
29cf076edbda Extending examples for some more good code bad code.
arunabha
parents: 0
diff changeset
    30
29cf076edbda Extending examples for some more good code bad code.
arunabha
parents: 0
diff changeset
    31
template <class T>
29cf076edbda Extending examples for some more good code bad code.
arunabha
parents: 0
diff changeset
    32
class list {
29cf076edbda Extending examples for some more good code bad code.
arunabha
parents: 0
diff changeset
    33
	public:
29cf076edbda Extending examples for some more good code bad code.
arunabha
parents: 0
diff changeset
    34
	typedef unsigned int myType;
29cf076edbda Extending examples for some more good code bad code.
arunabha
parents: 0
diff changeset
    35
	myType setSize (unsigned int x, unsigned int y);
29cf076edbda Extending examples for some more good code bad code.
arunabha
parents: 0
diff changeset
    36
	};
29cf076edbda Extending examples for some more good code bad code.
arunabha
parents: 0
diff changeset
    37
 
29cf076edbda Extending examples for some more good code bad code.
arunabha
parents: 0
diff changeset
    38
template<class T>	
29cf076edbda Extending examples for some more good code bad code.
arunabha
parents: 0
diff changeset
    39
inline  list<T>::myType list<T>::setSize (unsigned int x, unsigned int y) //This line will throw the error
29cf076edbda Extending examples for some more good code bad code.
arunabha
parents: 0
diff changeset
    40
29cf076edbda Extending examples for some more good code bad code.
arunabha
parents: 0
diff changeset
    41
	{  
29cf076edbda Extending examples for some more good code bad code.
arunabha
parents: 0
diff changeset
    42
         return (x*y);
29cf076edbda Extending examples for some more good code bad code.
arunabha
parents: 0
diff changeset
    43
	};
29cf076edbda Extending examples for some more good code bad code.
arunabha
parents: 0
diff changeset
    44
29cf076edbda Extending examples for some more good code bad code.
arunabha
parents: 0
diff changeset
    45
29cf076edbda Extending examples for some more good code bad code.
arunabha
parents: 0
diff changeset
    46
29cf076edbda Extending examples for some more good code bad code.
arunabha
parents: 0
diff changeset
    47
// Need to use  \x to specify the character code directly
29cf076edbda Extending examples for some more good code bad code.
arunabha
parents: 0
diff changeset
    48
char* literals()
29cf076edbda Extending examples for some more good code bad code.
arunabha
parents: 0
diff changeset
    49
   {
29cf076edbda Extending examples for some more good code bad code.
arunabha
parents: 0
diff changeset
    50
   char* string = "123£456";
29cf076edbda Extending examples for some more good code bad code.
arunabha
parents: 0
diff changeset
    51
29cf076edbda Extending examples for some more good code bad code.
arunabha
parents: 0
diff changeset
    52
   return string;
29cf076edbda Extending examples for some more good code bad code.
arunabha
parents: 0
diff changeset
    53
   }
29cf076edbda Extending examples for some more good code bad code.
arunabha
parents: 0
diff changeset
    54
29cf076edbda Extending examples for some more good code bad code.
arunabha
parents: 0
diff changeset
    55