author | arunabha |
Mon, 12 Apr 2010 16:01:06 +0100 | |
changeset 5 | 29cf076edbda |
parent 0 | fe474e3b08fb |
permissions | -rw-r--r-- |
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 Average(); // Removed classname |
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 |
//Use the keyword "Typename" when using an initialiser that has been Typedef'd inside a class template |
29cf076edbda
Extending examples for some more good code bad code.
arunabha
parents:
0
diff
changeset
|
29 |
// |
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 typename list<T>::myType list<T>::setSize (unsigned int x, unsigned int y){ //This line will NOT throw the error |
29cf076edbda
Extending examples for some more good code bad code.
arunabha
parents:
0
diff
changeset
|
40 |
return (x*y); |
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 |
|
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 |
//use \x to specify the character code directly |
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 |
char* literals() |
29cf076edbda
Extending examples for some more good code bad code.
arunabha
parents:
0
diff
changeset
|
47 |
{ |
29cf076edbda
Extending examples for some more good code bad code.
arunabha
parents:
0
diff
changeset
|
48 |
char* string = "123\x7e456"; // use \x to specify the character code directly |
29cf076edbda
Extending examples for some more good code bad code.
arunabha
parents:
0
diff
changeset
|
49 |
return string; |
29cf076edbda
Extending examples for some more good code bad code.
arunabha
parents:
0
diff
changeset
|
50 |
} |
29cf076edbda
Extending examples for some more good code bad code.
arunabha
parents:
0
diff
changeset
|
51 |