InterviewSolution
| 1. |
Solve : Visual Studio 2013 - cannot find specific file? |
|
Answer» Hello there, ...Please read over the ARTICLE above and come back here. I will not be able to help you personally, but somebody else will. Quote from: HitsugayaHisagi on September 24, 2014, 09:54:48 AM building was successNot if it was the code you provided. -getX() is declared as returning an int in the class definition, but your implementation has it defined as returning void. -you define an implementation for getY(), but the class has no definition. -Both the implementation getY/GetY methods have no return value, but you are trying to return values. -you reference cout and cin, but they are out of scope because you do not specify the std:: namespace either when you use them or in a "using namespace" statement. -the "#include" should be #include, because according to the C++ specifications standard C++ library header files do not have a .h file extension. I got it to compile by fixing these errors (fixing the getX() and getY() implementations, adding the getY() method to the class definition, adding "using namespace std;" after the includes, and changing iostream.h to iostream. Thank you so much for replying! I did some fixing on the program, but the problem is still there. Saying that... unable to start program, system cannot find specific file. Here's the edited one. //this serves as driver (main) for class Point //initiates the class Point and call methods from class Point #include using namespace std; int main() { //create a new instance of a class Point Point apoint; int x,y; cout<<"Type a nunmber for x:"; cin>> x; cout<<"Type a number for y:"; cin>> y; //invoke methods apoint.setX(x); apoint.setY(y); //display output via methods getX & getY cout<<"\n The numbers from the Point object are x = "<cout<<"\n y = "< return 0; } // program declares a class Point for var x & y class Point { private: int x,y; //point coordinate public: void setX(int val); void setY(int val); int getX(); int getY(); }; // class Point void Point::setX(int val) {x=val;}; void Point::setY(int val) {y=val;}; int Point::getX() {return x;}; int Point::getY() {return y;}; No building error. No warning. I did ask my friends about this problem too, but they weren't sure either. Some one suggested it could be the setting problem. Any suggestions on it? Or is it still the coding? Thank you again!! That doesn't build either. Code: [Select]Error 1 error C2065: 'Point' : undeclared IDENTIFIER testpoint.cpp 15 1 testPoint Error 2 error C2146: syntax error : missing ';' before identifier 'apoint' testpoint.cpp 15 1 testPoint Error 3 error C2065: 'apoint' : undeclared identifier testpoint.cpp 15 1 testPoint Error 4 error C2065: 'apoint' : undeclared identifier testpoint.cpp 24 1 testPoint Error 5 error C2228: left of '.setX' must have class/struct/union testpoint.cpp 24 1 testPoint Error 6 error C2065: 'apoint' : undeclared identifier testpoint.cpp 25 1 testPoint Error 7 error C2228: left of '.setY' must have class/struct/union testpoint.cpp 25 1 testPoint Error 8 error C2065: 'apoint' : undeclared identifier testpoint.cpp 29 1 testPoint Error 9 error C2228: left of '.getX' must have class/struct/union testpoint.cpp 29 1 testPoint Error 10 error C2065: 'apoint' : undeclared identifier testpoint.cpp 30 1 testPoint Error 11 error C2228: left of '.getY' must have class/struct/union testpoint.cpp 30 1 testPoint The Point class is declared AFTER you are using it. That doesn't work. If I move the class definition such that it appears before the main ROUTINE it works. |
|