0

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();

}

Edited by Dani: Formatting fixed

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by Gem74
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 ()

Edited by Ancient Dragon: n/a

Votes + Comments
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!

Edited by Gem74: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.