Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wektor_cpp
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Patryk Czarnik
wektor_cpp
Commits
26511aef
Commit
26511aef
authored
Apr 29, 2026
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
konstruktor kopiujący oraz operator=
parent
bf2f2b37
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
10 deletions
+22
-10
wektor.cpp
wektor.cpp
+19
-9
wektor.h
wektor.h
+3
-1
No files found.
wektor.cpp
View file @
26511aef
...
@@ -21,15 +21,25 @@ Wektor::Wektor()
...
@@ -21,15 +21,25 @@ Wektor::Wektor()
// co powodowałoby mnóstwo problemów:
// co powodowałoby mnóstwo problemów:
// - wzajemne nadpisywanie zawartości podczas operowania na dwóch zmiennych
// - wzajemne nadpisywanie zawartości podczas operowania na dwóch zmiennych
// - double free pod koniec życia obiektów
// - double free pod koniec życia obiektów
// Wektor::Wektor(const Wektor &zrodlowy)
Wektor
::
Wektor
(
const
Wektor
&
zrodlowy
)
// : rozmiar_tablicy{zrodlowy.rozmiar_tablicy},
:
rozmiar_tablicy
{
zrodlowy
.
rozmiar_tablicy
},
// liczba_elementow{zrodlowy.liczba_elementow}
liczba_elementow
{
zrodlowy
.
liczba_elementow
}
// {
{
// t = new TypWartosci[rozmiar_tablicy];
t
=
new
TypWartosci
[
rozmiar_tablicy
];
// for(TypIndeksu i=0; i<liczba_elementow; i++) {
for
(
TypIndeksu
i
=
0
;
i
<
liczba_elementow
;
i
++
)
{
// t[i] = zrodlowy.t[i];
t
[
i
]
=
zrodlowy
.
t
[
i
];
// }
}
// }
}
Wektor
&
Wektor
::
operator
=
(
const
Wektor
&
zrodlowy
)
{
rozmiar_tablicy
=
zrodlowy
.
rozmiar_tablicy
;
liczba_elementow
=
zrodlowy
.
liczba_elementow
;
t
=
new
TypWartosci
[
rozmiar_tablicy
];
for
(
TypIndeksu
i
=
0
;
i
<
liczba_elementow
;
i
++
)
{
t
[
i
]
=
zrodlowy
.
t
[
i
];
}
return
*
this
;
}
Wektor
::~
Wektor
()
{
Wektor
::~
Wektor
()
{
std
::
cout
<<
"destruct
\n
"
;
std
::
cout
<<
"destruct
\n
"
;
...
...
wektor.h
View file @
26511aef
...
@@ -20,7 +20,9 @@ class Wektor {
...
@@ -20,7 +20,9 @@ class Wektor {
public
:
public
:
Wektor
();
Wektor
();
//Wektor(const Wektor&);
Wektor
(
const
Wektor
&
);
Wektor
&
operator
=
(
const
Wektor
&
);
~
Wektor
();
~
Wektor
();
...
...
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