Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Prog2
/
labor_peldak
/
lab_09
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
A prog2-höz tartozó friss repo anyagok itt elérhetőek:
https://git.iit.bme.hu/
Commit
aa3ae867
authored
Apr 25, 2019
by
Szeberényi Imre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
const_iterator kommentek
parent
c68a49e6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
8 deletions
+13
-8
genArray3/gen_array_iter3.hpp
+13
-8
No files found.
genArray3/gen_array_iter3.hpp
View file @
aa3ae867
...
...
@@ -57,7 +57,7 @@ public:
/// létrehoz egy konstans objektumra alkalmazható iterátort és az elejére állítja
/// @return - iterátor az adatsorozat elejére
const_iterator
begin
()
const
{
return
const_iterator
(
*
this
);
// ld. iterátor konstruktor
return
const_iterator
(
*
this
);
// ld. iterátor konstruktor
}
/// létrehoz egy iterátort és az utolsó elem után állítja
...
...
@@ -126,13 +126,13 @@ public:
/// egyenlőtlenség vizsgálat
/// @param i - jobboldali operandus
bool
operator
!=
(
const
iterator
&
i
)
{
bool
operator
!=
(
const
iterator
&
i
)
const
{
return
(
idx
!=
i
.
idx
);
}
/// egyenlőség vizsgálat
/// @param i - jobboldali operandus
bool
operator
==
(
const
iterator
&
i
)
{
bool
operator
==
(
const
iterator
&
i
)
const
{
return
!
operator
!=
(
i
);
}
...
...
@@ -143,14 +143,17 @@ public:
}
/// Szelekció pointerrel (nyíl). Címet kell, hogy adjon.
T
*
operator
->
()
{
T
*
operator
->
()
const
{
return
&
operator
*
();
}
};
// iterator osztály vége
/// const_iterator osztály
/// const_iterator osztály
.
/// Visszavezetjük az iterator osztályra.
/// A kompatibilitas miatt azonban a conts_itarator betehető egy itaratorba, így
/// a kontans objektum adata is elérhetővé válik balértékként is.
/// Privat öröklés jobb megoldás lenne, úgy azonban minden tagfüggvényt az ősből delegálni kell.
class
const_iterator
:
public
iterator
{
public
:
/// default konstruktor
...
...
@@ -160,10 +163,12 @@ public:
/// @param a - a konkrét objektum
/// @param ix - ide állítja az indexet
const_iterator
(
const
Array
&
a
,
size_t
ix
=
0
)
:
iterator
(
const_cast
<
Array
&>
(
a
),
ix
)
{}
/// Kis trükközés a kasztolással...
:
iterator
(
const_cast
<
Array
&>
(
a
),
ix
)
{}
/// Kis trükközés a kasztolással: Levesszük a
/// konstans attribútumot, de nem fogjuk írni.
const
T
&
operator
*
()
const
{
return
iterator
::
operator
*
();
/// indirekció
const
T
&
operator
*
()
const
{
/// Ezen keresztül biztosan nem fogjuk írni, de sajnos a kompatibilitás
return
iterator
::
operator
*
();
/// miatt egy const_itarator -> itarator konverzió nem kerül semmibe...
}
/// Szelekció pointerrel (nyil). Címet kell, hogy adjon.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment