when I compile, there are no errors, but when I run the program it tells me there are build errors and then "the system cannot find the file specified." I have copied and restarted a new project, then new item and still get same error message. Can someone tell me what the error is? Thanks.

#include <iostream>
using namespace std;

class testClass
{public:
    int sum();
    void print();
    testClass();
    testClass(int a, int b);

private:
    int x;
    int y;
};

int testClass :: sum ()
{return x + y;}

testClass :: testClass (int a, int b)
{ x=a, y=b ; }

testClass :: testClass ()
{ x=0, y=0 ; }

void print ()
{cout << "Sum of one, a + b = " << endl;
cout << "Sum of two, a + b = " << endl;
}


/* an entry point for program execution */
int main()
{
testClass one;          //default constructor called
testClass two (2,2);    //constructor with 2 values called
one.print();
two.print();

}

>>when I compile, there are no errors,
Ditch the compiler and use a different one. There is a link error.

>>void print ()

Wrong. should be void testClass::print ()

commented: It worked! error solved! +0

>>when I compile, there are no errors,
Ditch the compiler and use a different one. There is a link error.


>>void print ()

Wrong. should be void testClass::print ()

ok, Great! Thank you, this worked, it ran! I thought I had tried this but guess I didn't.

Thanks!

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.