Just wondering if C++ has a standard equivalent of the Vector2/3/4 (structures I think?) in C#?
Edit: For clarification a XNA C# Vector2/3/4 "structures" (I'm not entirely sure what they are) basically hold 2, 3, or 4 float values like a struct in C++ defined as:
struct Vector3
{
float x, y, z;
};
I've been basically using just that code in C++, but I was hoping for a standard alternative and was unable to find one.
C89. The ANSI standard was completed in 1989 and ratified as ANSI X3. 159-1989 "Programming Language C." This version of the language is often referred to as "ANSI C". Later on sometimes the label "C89" is used to distinguish it from C90 but using the same labeling method.
Let's continue with a discussion of all the five different standards of C — K&R C, ANSI C, C99, C11 and Embedded C. For the purposes of our discussion, the compiler used is the gcc C compiler from the GNU Compiler Collection (GCC). If there are five different standards for C, which one is the default standard of gcc?
ANSI C merely refers to a particular standard for the C Programming Language - i.e. there is no difference, they refer to the same thing.
Compared to C, C++ has significantly more libraries and functions to use. If you're working with complex software, C++ is a better fit because you have more libraries to rely on. Thinking practically, having knowledge of C++ is often a requirement for a variety of programming roles.
The Vector3 struct in C# is from XNA, not the base class libraries.
The equivelent in C++ would be to use XMFLOAT3.
Nothing standard that I know of, but here's some code to get you started
http://www.flipcode.com/archives/Faster_Vector_Math_Using_Templates.shtml
If you are using C++/CLI and targeting Windows and .NET, you can use Vector2, etc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With