0
네 개의 다른 매개 변수 (이름, 아티스트, 크기 및 날짜)를 입력하는 구조가 하나 있습니다.하지만 구조체의 라이브러리 인 다른 구조체를 가지고 있습니다. 라이브러리 구조에서 라이브러리에 삽입 할 항목 인 인수 하나를 사용하는 insert memeber 함수를 만들고 싶습니다. header.h가있는C++ : 구조체 내의 멤버 함수
struct MusicEntry{
string name, artist, date_added;
long size;
MusicEntry() = default;
MusicEntry(string name_str, string artist_str, long size_int, string date_added_str) :
name(name_str), artist(artist_str), size(size_int), date_added(date_added_str) {};
MusicEntry to_string();
};
struct MusicLibrary{
MusicLibrary(string) {};
MusicLibrary to_string();
MusicEntry insert(); //not sure how this should be passed with MusicEntry
};
FUNCTION.cpp에 각 노래는 고유 ID를 구비하고 그 essentialy 삽입 부재를 통하여 전달되는 무엇이다
MusicEntry MusicLibrary::insert(){
//some code
}
기능.
당신은'무효 삽입 (const를 MusicEntry &)을 찾고 계십니까? 인수를 취하는 함수를 원하지만 코드는 아무 것도 취하지 않는 함수를 표시한다고 가정합니다. –
필자는이 글을 쓰는 방법을 잘 모르기 때문에 필자가 작성한 코드를 지금 막 게시했습니다. – Tyler