returning a list STL

How can i return a STL list?

I tried doing this
1
2
3
4
5
6
7
8
  Course* Schedule::getAllCourses(){
  Course* array = new Course[courses.size()]; // create a dynamic array  
  
  std::copy(courses.begin(), courses.end(), array); // copy the data  

	return array;
}


but i get error since they have different types.

any suggestions?
What is "courses"?

See the range constructor in http://www.cplusplus.com/reference/list/list/list/
it is a list in course.

Is there a way to do so without using constructors? i wanna simply return a list that i have.
keskiverto wrote:
What is "courses"?
std::list<int>
http://www.cplusplus.com/forum/beginner/132580/
"Simply return." A copy or a const reference?

In both cases:
1
2
3
{
  return courses;
}
Topic archived. No new replies allowed.