-
June 10th, 2004, 07:56 PM
#1
Vector gives compiler errors?
Consider the following code:
Code:
//--Header-Files----------------------------------
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#include <vector>
//------------------------------------------------
//--Global-Variables------------------------------
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
double CoordinateMultiplierX = 0; //Size of X axis increment in Pixels
double CoordinateMultiplierY = 0; //Size of Y axis increment in pixels
int MapX = 0; //Size of Client Rectangle X
int MapY = 0; //Size of Client Rectangle Y
//------------------------------------------------
//--Structures------------------------------------
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
struct Points {
double x;
double y;
bool Invisible; //TRUE = Move to, FALSE = Line to
Points(double xx, double yy, bool i) {
x = xx * CoordinateMultiplierX;
y = yy * CoordinateMultiplierY;
Invisible = i; } };
//------------------------------------------------
//--Vector-Declarations---------------------------
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
vector<Points> MapPoints ; //Contains points to draw Map Lines
//------------------------------------------------
Here are the errors my compiler gives. I'm using Visual Studio .NET 2003:
Code:
error C2143: syntax error : missing ';' before '<'
error C2501: 'vector' : missing storage-class or type specifiers
error C2065: 'MapPoints' : undeclared identifier
Can someone please tell me why these errors occur? I can't seem to figure it out
-
June 10th, 2004, 08:03 PM
#2
Use std::vector<Points> MapPoints in your code instead. This is the compiler can't find vector in the global namespace. Thus, you need to specify the std namespace.
-
June 13th, 2004, 04:53 AM
#3
In addition...the following shows you the four different methods to map a namespace...
Code:
// Using the full member name, including the namespace it belongs to:
std::cout << "Hello World";
// By taking advantage of Using-Declarations:
using std::cout; // This declares cout in the current
// scope as synonym for std::cout
cout << "Hello World";
// By taking advantage of Using-Directives:
using namespace std; // Which specifies that the current
// scope can refer to names in the
// 'std' namespace without using
// full qualifiers. This is mostly
// used when porting legacy code.
cout << "Hello World";
// Using aliases:
namespace X
{
namespace Y
{
class Z { ... };
}
}
X::Y::Z // The full qualifier for 'Z' is
// 'X::Y::Z'
namespace w = X::Y; // This declares 'w' as an alias for
// namespace 'X::Y'
w::Z // Access 'Z' using 'w::Z'
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|