error while debugging

Im trying to create a quadratic equation using class, and to put some values into it. first i was trying to print it in the form of "ax^2 + bx + c" and second i was trying to evaluate it at given x.


#include <iostream>
using namespace std;

class Quadratic {
private:
int a;
int b;
int c;
public:
Quadratic(int d1, int d2, int d3){
a=d1;
b=d2;
c=d3;}
void print();
int evaluate (int x);
};

void Quadratic::print()
{
cout<<a<<"x^2 + "<<b<<"x + "<<c;
}

int Quadratic::evaluate(int x)
{
return (a * x * x) + (b * x) + c;
}

int main()
{
Quadratic p(1,5,3),q(1,2,1);
cout<<"p: ";p.print();
cout<<"q: ";q.print();
cout<<"p(2)="<<p.evaluate(2)<<endl;
return 0;
}




'project.exe': Loaded 'C:\Users\Fares\Documents\Visual Studio 2010\Projects\project\Debug\project.exe', Symbols loaded.
'project.exe': Loaded 'C:\Windows\SysWOW64\ntdll.dll', Cannot find or open the PDB file
'project.exe': Loaded 'C:\Windows\SysWOW64\kernel32.dll', Cannot find or open the PDB file
'project.exe': Loaded 'C:\Windows\SysWOW64\KernelBase.dll', Cannot find or open the PDB file
'project.exe': Loaded 'C:\Windows\SysWOW64\msvcp100d.dll', Symbols loaded.
'project.exe': Loaded 'C:\Windows\SysWOW64\msvcr100d.dll', Symbols loaded.
The program '[6592] project.exe: Native' has exited with code 0 (0x0).
Theres nothing wrong with the actual code. Can you try restarting your IDE?

Edit: I had pretty much the same errors a while ago, fixed itself really. Try googling it.
Last edited on
The problem is your program ran and exited so quickly you never saw the output.
See the following thread:
http://www.cplusplus.com/forum/beginner/1988/

Before the return 0 in main(), put:
 
  system ("pause");

and you will see the output from your program.

PLEASE USE CODE TAGS (the <> formatting button) when posting code.
http://v2.cplusplus.com/articles/jEywvCM9/
It makes it easier to read your code and it also makes it easier to respond to your post.
Hint: You can edit your previous post, highlight your code and press the <> formatting button.

Last edited on
closed account (2LzbRXSz)
System functions aren't entirely recommended though (I mean, for a quick fix and in this situation it makes sense). If you're going to pause in the future though I recommend using http://www.cplusplus.com/reference/thread/this_thread/sleep_for/ It's straightforward, and gets the job done.
Does anyone know why Microsoft doesnt just make a feature that does this automatically, because codeblocks does this, and Im pretty sure Microsoft can aswell.
try to put evaluate and print inside the class.
try to put evaluate and print inside the class.

They are members of the class.

Topic archived. No new replies allowed.