More consistent formatting of examples in documentation
This commit is contained in:
parent
8753f9652c
commit
7ee76f93f9
9 changed files with 96 additions and 99 deletions
|
|
@ -2958,29 +2958,29 @@ To illustrate, consider the following template definition:
|
|||
<div class="code"><pre>
|
||||
template<class T> class List {
|
||||
private:
|
||||
T *data;
|
||||
int nitems;
|
||||
int maxitems;
|
||||
T *data;
|
||||
int nitems;
|
||||
int maxitems;
|
||||
public:
|
||||
List(int max) {
|
||||
data = new T [max];
|
||||
nitems = 0;
|
||||
maxitems = max;
|
||||
}
|
||||
~List() {
|
||||
delete [] data;
|
||||
};
|
||||
void append(T obj) {
|
||||
if (nitems < maxitems) {
|
||||
data[nitems++] = obj;
|
||||
}
|
||||
}
|
||||
int length() {
|
||||
return nitems;
|
||||
}
|
||||
T get(int n) {
|
||||
return data[n];
|
||||
List(int max) {
|
||||
data = new T [max];
|
||||
nitems = 0;
|
||||
maxitems = max;
|
||||
}
|
||||
~List() {
|
||||
delete [] data;
|
||||
};
|
||||
void append(T obj) {
|
||||
if (nitems < maxitems) {
|
||||
data[nitems++] = obj;
|
||||
}
|
||||
}
|
||||
int length() {
|
||||
return nitems;
|
||||
}
|
||||
T get(int n) {
|
||||
return data[n];
|
||||
}
|
||||
};
|
||||
</pre></div>
|
||||
|
||||
|
|
@ -3704,10 +3704,10 @@ template <class T> class OuterTemplateClass {};
|
|||
// Don't forget to use %feature("flatnested") for OuterClass::InnerStruct and
|
||||
// OuterClass::InnerClass if the target language doesn't support nested classes.
|
||||
class OuterClass {
|
||||
public:
|
||||
// Forward declarations:
|
||||
struct InnerStruct;
|
||||
class InnerClass;
|
||||
public:
|
||||
// Forward declarations:
|
||||
struct InnerStruct;
|
||||
class InnerClass;
|
||||
};
|
||||
|
||||
struct OuterClass::InnerStruct {};
|
||||
|
|
@ -4533,13 +4533,13 @@ around some other class. For example:
|
|||
<pre>
|
||||
// Smart-pointer class
|
||||
template<class T> class SmartPtr {
|
||||
T *pointee;
|
||||
T *pointee;
|
||||
public:
|
||||
SmartPtr(T *p) : pointee(p) { ... }
|
||||
T *operator->() {
|
||||
return pointee;
|
||||
}
|
||||
...
|
||||
SmartPtr(T *p) : pointee(p) { ... }
|
||||
T *operator->() {
|
||||
return pointee;
|
||||
}
|
||||
...
|
||||
};
|
||||
|
||||
// Ordinary class
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue