cout<< "Gradeform "<< formId<< " has been added to Course "<< courseId<<endl; return; } } cout<<"Course" << courseId << " does not exist"<<endl; }
sorun tam olarak bu kodda mı onu da bilmiyorum aslında, çünkü program artık hiçbir şekilde pointer arrayi tanımlamama izin vermiyor.
new Operator (C++) ...... If unsuccessful, new returns zero or throws an exception; see The new and delete Operators for more information. You can change this default behavior by writing a custom exception-handling routine and calling the _set_new_handler run-time library function with your function name as its argument.
......
The class describes an exception thrown to indicate that an allocation request did not succeed.
class bad_alloc : public exception { bad_alloc(const char *_Message); bad_alloc(); virtual ~bad_alloc(); };
Remarks An instance of bad_alloc can be constructed from a message or from a message string with no memory allocation.
The value returned by what is an implementation-defined C string. None of the member functions throw any exceptions.
Requirements Header: <new>
Namespace: std
Example Copy Code // bad_alloc.cpp // compile with: /EHsc #include<new> #include<iostream> using namespace std;
courses.numberOfStudents in değerinin o satırda ne olduğuna dikkat edin. courses bir sınıf ise sınıf kurucularında numberOfStudents e mantıklı bir atama yapmak gerek.