1.

Solve : Visual Studio 2013 - cannot find specific file?

Answer»

Hello there,

Sorry if this post has once been POSTED (I couldn't find a related one).

I am new to Visual studio 2013, and I have been trying out the basics of Object Oriented Programming in C++ for class and object. I tried to run my code on VS, building was success, but when it comes to debugging, it says the system cannot find the file specified, ie project.exe. here's my code that I tried from a book:

// program declares a class Point for var x & y

#include

class Point
{
private:
int x,y; //point coordinate
public:
void setX(int val);
void setY(int val);
int getX();
}; // class Point

void Point::setX(int val)
{x=val;};

void Point::setY(int val)
{y=val;};

void Point::getX()
{return x;};

void Point::getY()
{return y;};


//this serves as driver (main) for class Point
//initiates the class Point and CALL methods from class Point

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;
}

What could be the problem? Once in a while I also encounter this problem when I tried out C codes. Is there any setting in VS that I should change? Or anything that I should include in my code?

Thank you so much!! This i only a generalized response.
MS Visual Studio programs often have two objectives that are mutually elusive.
One is to produce code ready for real-time debugging.
The other is to create lean code for distribution to end-users.
In other words, the debug features add to the payload.

Check you documentation about how to prepare code for debugging.
http://msdn.microsoft.com/en-us/library/sc65sadd.aspx
Debugging in Visual Studio
Quote

...
Debug Settings and Preparation

Covers the Project Property settings and setup you must perform to create a debug build for your project. Also covers setup for remote debugging, debugging Code Center Premium source, debugging a partial-trust application, and debugging a high-performance cluster application.
...
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 success
Not 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.


Discussion

No Comment Found