Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
Algorithm_Python_2021/c_to_cpp/a0vector2.cpp at master · SoniaComp/Algorithm_Python_2021 · GitHub
Skip to content
Navigation Menu
Sign in
Appearance settings
Platform
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
Solutions
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
View all industries
View all solutions
Resources
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
Open Source
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
Enterprise
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
SoniaComp
/
Algorithm_Python_2021
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
0
Pull requests
2
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Files
Expand file tree
master
Breadcrumbs
Algorithm_Python_2021
/
c_to_cpp
/
a0vector2.cpp
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
99 lines (86 loc) · 2.45 KB
master
Breadcrumbs
Algorithm_Python_2021
/
c_to_cpp
/
a0vector2.cpp
Copy path
Top
File metadata and controls
Code
Blame
99 lines (86 loc) · 2.45 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#
include
<
iostream
>
#
include
<
vector
>
using
namespace
std
;
//
데이터를 효율적으로 관리
//
배열: index 로 접근
//
------------- 객체 배열: 배열의 요소가 객체가 됨 ------------- //
//
단점: 배열 크기 변경 불가
//
배열 요소가 객체로 구성된 배열로 일반 배열과 같이 사용한다.
class
Book
{
private:
string name;
int
no;
public:
Book
() { cout <<
"
--- Constructor ---
"
<< endl; }
Book
(string s,
int
n)
{
cout <<
"
--- Constructor ---
"
<< endl;
name = s;
no = n;
}
void
setName
(string s) { name = s; }
void
setNo
(
int
n) { no = n; }
string
getName
() {
return
name; }
int
getNo
() {
return
no; }
};
//
int main()
//
{
//
Book books[5];
//
Book books2[5] = {
//
Book("c", 1),
//
Book("C++", 2),
//
Book("Java", 3)};
//
Book books3[] = {
//
Book("c", 1),
//
Book("C++", 2)
//
};
//
}
//
------------- 벡터 ------------- //
//
배열 크기 변경 가능
//
정적인 배열의 단점을 보완한 동적 배열로 데이터를 쉽고 효율적으로 관리할 수 있다.
class
BankAccount
{
private:
string a_name;
int
a_no;
public:
BankAccount
() { cout <<
"
--- Constructor ---
"
<< endl; }
BankAccount
(string s,
int
n)
{
cout <<
"
--- Constructor ---
"
<< endl;
a_name = s;
a_no = n;
}
void
setName
(string s) { a_name = s; }
void
setNo
(
int
n) { a_no = n; }
string
getName
() {
return
a_name; }
int
getNo
() {
return
a_no; }
};
int
main
()
{
vector<BankAccount>
bankAccounts
(
5
);
bankAccounts[
0
].
setName
(
"
박찬호
"
);
bankAccounts[
0
].
setNo
(
1
);
//
추가 (배열의 크기를 늘림)
BankAccount ac =
BankAccount
();
bankAccounts.
push_back
(ac);
//
BankAccount 객체를 늘리는데, 그 객체의 이름을 넣어준다.
//
제거
bankAccounts.
pop_back
();
//
크기
bankAccounts.
size
();
//
반복자
vector<BankAccount>::iterator iter;
//
내가 사용하고 있는 벡터의 iterator를 만들어주고 그것의 인스턴스 명을 iter로 지정한다.
//
처음 주소값 이후 하나씩 하나씩 이동하면서 요소를 가리킨다.
//
처음 인스턴스 주소값
iter = bankAccounts.
begin
();
//
마지막 인스턴스 주소값 +1
iter = bankAccounts.
end
();
//
제거
//
- 배열의 요소를 삭제.. iter가 가리키고 있는 요소가 제거된다.
//
end() 위치에 있을 경우 한칸 앞으로 와서 맨 마지막 요소를 제거
bankAccounts.
erase
(iter);
return
1
;
}
You can’t perform that action at this time.