Как манипулировать этим динамическим вектором для сгибаC++

Программы на C++. Форум разработчиков
Ответить
Anonymous
 Как манипулировать этим динамическим вектором для сгиба

Сообщение Anonymous »

Я работаю с Flex/Bison, чтобы создать интерпретатора для класса. Проблема, с которой я сталкиваюсь, по -видимому, связана с использованием/преобразованием динамического вектора. Я пытаюсь создать функцию для оценки сгибающих операций, но я попал в контрольно -пропускной пункт. Тип списка указан как динамический вектор, чтобы разрешить любое количество аргументов, чтобы быть передано ему. < /P>
%union {
CharPtr iden;
Operators oper;
double value;
vector* list;
}
< /code>
%type list expressions list_choice
< /code>
The bison direction is to pass the direction of the fold, the operator for the fold, and the dynamic vector to the function evaulateFold().
FOLD direction operator list_choice ENDFOLD SEMICOLON {$$ = evaluateFold($2, $3, $4);}
< /code>
Once I get it to this point, I cannot do anything with the dynamic array. I tried to copy it to a regular array using for loops but it says that there is no start point reference for the dynamic array. I tried passing the array to evaluateFold() Использование,const std::vector& Значения, но затем говорится, что нет способа преобразовать std :: vector * в std :: vector & . Как я должен иметь возможность использовать этот массив для функции? < /P>
double evaluateFold(Operators direction, Operators action, vector* values){

double result = 0;
switch(direction){
case LFOLD:
switch(action){
case SUBTRACT:
subFromLeft(values);
for (auto i : values)
cout
If anybody could help me resolve this, or at least point me in the right direction, that would be awesome. It is more a question of C++ than flex/bison, but maybe there is some trick in flex/bison that I am not aware of that will help me.
Below is a sample of what the fold function would interpret/evaluate.
// Test Left Fold

function main returns integer;
begin
fold left - (3, 2, 1) endfold;
end;


Подробнее здесь: https://stackoverflow.com/questions/794 ... operations
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «C++»