Hello!
I am studying C ++. The teacher on the monitor code in VS 2008 works, I have in VS 2010 does not work. Checked, everything is written correctly (ie, as a teacher).
The code itself (divided into 3 files):
//Определение класса Point #ifndef POINT_H #define POINT_H class Point { private: int x, y; public: int GetX() {return x;} //inline по умолчанию int GetY(); void SetX(int); void SetY(int); }; inline int Point::GetY() { return y; } #endif
2 file:
//Реализация класса Point #include"Point.h" void SetX(int _x) { x = _x >= 0 ? _x : 0; } void SetY(int _y) { y = _y >= 0 ? _y : 0; }
3 file:
//Использованиие класса Point (клиентский код) #include<iostream> #include"Point.h" using namespace std; int main() { Point a; a.SetX(10); a.SetY(20); cout << a.GetX() << ", " << a.GetY() << endl; system("pause"); }
VS 2010 debugger error code:
1>------ Построение начато: проект: Point, Конфигурация: Debug Win32 ------ 1>Построение начато 21.01.2012 21:14:51. 1>InitializeBuildStatus: 1> Обращение к "Debug\Point.unsuccessfulbuild". 1>ClCompile: 1> usePoint.cpp 1> Point.cpp 1>c:\users\vladislav\documents\visual studio 2010\projects\point\point.cpp(9): error C2065: x: необъявленный идентификатор 1>c:\users\vladislav\documents\visual studio 2010\projects\point\point.cpp(16): error C2065: y: необъявленный идентификатор 1> Создание кода... 1> 1>СБОЙ построения. 1> 1>Затраченное время: 00:00:00.55 ========== Построение: успешно: 0, с ошибками: 1, без изменений: 0, пропущено: 0 ==========
What could be the cause? Project console (empty).
Grateful for the help. Thank.