Managed Vector class with List<T> bad suffix on number

Trying to create a basic vetor class using managed C++\CLI List. I'm new at this, so be gentle ;-)

Heade file MyVec.h

#pragma once

using namespace System::Collections::Generic;

ref class MyVec
{
private:
    List<double>^ MyVector;

public:
    MyVec(void);

    property List<double>^ myVector
    {
        List<double>^ get();
        void set(List<double>^ MyVector);
    }

    MyVec^ operator+(MyVec^ 2ndVec);

};

Here I get a "bad suffix on number" where I try to overload + to add two vectors.

CPP file MyVec.CPP:

#include "StdAfx.h"
#include "MyVec.h"

List<double>^ MyVec::myVector::get()
{
    return MyVector;
}
void MyVec::myVector::set(List<double>^ myVector)
{
    this->MyVector = myVector; 
}
MyVec^ operator+(MyVec^ 2ndVec)
{
    MyVec^ SumVec = gcnew MyVec();
    if 2ndVec->Count == this->Count
    {
        for (int i = 0; i < this->Count; i++)
        {
            SumVec[i] = this[i] + 2ndVec[i];
            return SumVec;
        }
    }
}
MyVec::MyVec(void)

So whats wrong with the overloading?

Thanks, Jan

Answers


The error is saying the lexer doesn't allow ndVec to be a suffix for the literal number 2. It seems your intention is to write an identifier, not a literal number. But, 2ndVec is not a legal identifier in C++/CLI.

A legal identifier consists of letters, digits and underscores. It cannot begin with a digit. An identifier that contains a double underscore or begins with an underscore followed by an uppercase letter is reserved for the implementation.


Need Your Help

Sum of fields using LINQ

c# linq sql-server-ce

Some background before asking my question.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.