Hello


pleas any one helpe me in my code


my code include error


iam convert thise function to over loading(laste function)
but include error


Code:

bool Student::operator!()
{
     if(!canRegisterMore())
     return true;
     else
     return false;
}
bool Student::registerCourse(Course course) 
 
 //thise function expline abilety of register course but you should
 //the 1 can register more is true and 2 add currentcridet and number of cridet<10
 
{  
     
    if (canRegisterMore() &&(currentcredits+ course.getNumberOfCridet())<=10)  
    {   
        cout << "You can register course "<<endl;
		
		currentcredits+= course.getNumberOfCridet();
		
        return true;  
    }  
    else  
    {  
         cout << "Sory you cannot Register course !"<<endl;  
         return false;  
    }
}
  
  Student Student::operator+(const Course& courseObj)
  {
       Student studentObj;
       if(!studentObj&&(studentObj.currentcredits+courseObj.getNumberOfCridet()<=10)
       {
        {                                                                           
       cout << "You can register course "<<endl;                                                                           
       studentObj.currentcredits=currentcredits+courseObj.getNumberOfCridet();
       return studentObj;
       }
      
       else
       cout << "Sory you cannot Register course !"<<endl;  
       return false;
       }
  }

I hope helpe me:(

Member Avatar for jencas

Error message???

Compiler: Default compiler
Building Makefile: "C:\Documents and Settings\ÃãíÑå ÃãíÑå\Desktop\Project2\Makefile.win"
Executing make...
make.exe -f "C:\Documents and Settings\ÃãíÑå ÃãíÑå\Desktop\Project2\Makefile.win" all
g++.exe -c student.cpp -o student.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include"

student.cpp: In member function `Student Student::operator+(const Course&)':
student.cpp:67: error: no matching function for call to `Student::Student()'
student.h:21: note: candidates are: Student::Student(const Student&)
student.cpp:15: note: Student::Student(std::string, Date)
student.cpp:68: error: passing `const Course' as `this' argument of `int Course::getNumberOfCridet()' discards qualifiers
student.cpp:69: error: expected `)' before '{' token
student.cpp:80: error: expected primary-expression before '}' token
student.cpp:80: error: expected `;' before '}' token

make.exe: *** [student.o] Error 1

Execution terminated

1. Why the last statement of Student Student::operator+ is return false ? Are you sure that one Student added to another Student is a Student again? ;)
2. Look at braces in this operator body. Why you wrote two braces one after another in if statement?
3. Don't print messages in operator bodies. It's a very strange operator side effect.
4. Avoid this cumbersom Pascal-like style as in your bool Student::operator! implementation. Keep it simpler:

bool Student::operator !()
{
     return ! canRegisterMore(); // that's all, folks...
}

iam putit last statmwnt return fallse if the header if statment lessthan 10...!

iam put{after if statment because contain mor than one statment

These errors only irrational!

???????

please any one helpe me

It seems you lack the basics of netiquette, so allow me educate you. Bumping a thread (ie. replying with pointless posts in an attempt to move your thread to the top of the list) is extremely rude and selfish. It suggests that you believe yourself to be more important than everyone else, including those of us who volunteer our time to help those in need.

It's often a counter-productive practice, as many people will be insulted enough to completely ignore you after an excessive amount of bumping. For example, it would be faster and easier for me to answer your question, but out of principle I'm taking the time to shoot you down with the hope that you won't repeat the same mistake again.

You're welcome.

You didn't post your whole source file, so the line numbers don't line up...

student.cpp: In member function `Student Student::operator+(const Course&)':
student.cpp:67: error: no matching function for call to `Student::Student()'
student.h:21: note: candidates are: Student::Student(const Student&)
student.cpp:15: note: Student::Student(std::string, Date)

The above error indicates that your operator+ implementation is creating a new instance of Student using the default (no-parameter) constructor, but that you have not defined the default constructor.

student.cpp:68: error: passing `const Course' as `this' argument of `int Course::getNumberOfCridet()' discards qualifiers
student.cpp:69: error: expected `)' before '{' token
student.cpp:80: error: expected primary-expression before '}' token
student.cpp:80: error: expected `;' before '}' token

I think this last set is based on line 69. I suspect you have an 'if' statement that doesn't have enough parens. Something like the following would generate that type of error:

if (x == (average(b, c)) {

PS- I agree with Narue, bumping your post doesn't help.

Note: these forums are not INSTANT. Generally, if you have a concise and clear question your reply will be rapid, but don't expect instant responses. I believe we're all donating our time here, to even look at your questions...appreciate the help you do get.

Indeed, the more time you put into writing your question. Making it clear and clean. The better laid out and grammatically correct, the faster and more accurate your reply will be. Just remember that, the more time you put in the more of others time you get back. It's simple and true.

Chris

iam sad>>>

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.