Форум программистов, компьютерный форум, киберфорум
C++
Войти
Регистрация
Восстановить пароль
Карта форума Темы раздела Блоги Сообщество Поиск Заказать работу  
 
Рейтинг 4.67/6: Рейтинг темы: голосов - 6, средняя оценка - 4.67
0 / 0 / 0
Регистрация: 30.10.2014
Сообщений: 22
1

Ошибка parameter declared 'auto'

23.10.2016, 20:16. Показов 1112. Ответов 4
Метки нет (Все метки)

Author24 — интернет-сервис помощи студентам
Код:
C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
#include <algorithm>
#include <iostream>
#include <set>
#include <vector>
///////////////////////////////////////////////////////////////////////////////
class   T_official;
///////////////////////////////////////////////////////////////////////////////
typedef T_official  *                       T_off_tree;
typedef std::vector     < T_off_tree    >   T_off_trees;
typedef int                                 T_id;
typedef std::set        < T_id          >   T_ids;
///////////////////////////////////////////////////////////////////////////////
struct  T_resolution
{
    //---------------------------------------------------------------------
    int     price_;
    T_ids   actors_ids_;
    int     full_price_     =   {};
    //---------------------------------------------------------------------
    T_resolution
        (
            int                 price,
            T_ids   const   &   actors_ids
        )
        :
        price_          ( price         ),
        actors_ids_     ( actors_ids    )
    {}
    //---------------------------------------------------------------------
};
///////////////////////////////////////////////////////////////////////////////
typedef std::vector     < T_resolution  >   T_resolutions;
///////////////////////////////////////////////////////////////////////////////
class   T_official
{
    //-------------------------------------------------------------------------
    int                         id_;
    T_resolutions               resolutions_;
 
    T_off_trees                 sub_trees_;
    T_resolutions::iterator     res_min_it_             =   resolutions_.end();
    int                         price_min_              =   {};
    bool                        price_min_is_valid_     =   {};
    //-------------------------------------------------------------------------
public:
    //-------------------------------------------------------------------------
    T_official
        (
            int                         id,
            T_resolutions   const   &   resolutions
        )
        :
        id_             ( id ),
        resolutions_    ( resolutions )
    {}
    //-------------------------------------------------------------------------
    void    print_price_min_and_id_of_actors_of_price_min()
    {
        std::cout   <<  get_price_min()
                    <<  std::endl;
 
        print_id_and_id_of_price_min_actors();
        std::cout   <<  std::endl;
    }
    //-------------------------------------------------------------------------
    void    add_sub( T_off_tree     const   &   off_tree )
    {
        sub_trees_.emplace_back( off_tree );
    }
    //-------------------------------------------------------------------------
private:
    //-------------------------------------------------------------------------
    int     get_price_min()
    {
        set_price_min_if_not_valid();
        return  price_min_;
    }
    //-------------------------------------------------------------------------
    void    set_price_min_if_not_valid()
    {
        if  (
                price_min_is_valid_
            )
        {
            return;
        }
 
        price_min_is_valid_     =   true;
 
        for( auto   &   res     :   resolutions_ )
        {
            set_res_full_price( res );
        }
 
        set_res_min_it();
        price_min_  =   res_min_it_->full_price_;
    }
    //-------------------------------------------------------------------------
    void    set_res_full_price( T_resolution    &   res )
    {
        res.full_price_     =   res.price_;
 
        for( auto   actor_id    :   res.actors_ids_ )
        {
            auto    const   &   sub_tree_it     =   get_sub_tree_it( actor_id );
 
            if  (
                    sub_tree_it     !=  sub_trees_.end()
                )
            {
                res.full_price_     +=  ( *sub_tree_it )->get_price_min();
            }
        }//for
    }
    //-------------------------------------------------------------------------
    void    set_res_min_it()
    {
        res_min_it_     =   std::min_element
                                (
                                    resolutions_.begin  (),
                                    resolutions_.end    (),
 
                                    []                  (
                                                            auto    const   &   L_res,
                                                            auto    const   &   R_res
                                                        )
                                    {
                                        return      L_res.full_price_
                                                <   R_res.full_price_;
                                    }
                                );
    }
    //-------------------------------------------------------------------------
    void    print_id_and_id_of_price_min_actors()                           const
    {
        std::cout   <<  id_
                    <<  '\t';
 
        if  (
                    res_min_it_
                ==  resolutions_.end()
            )
        {
            return;
        }
 
        for( auto   actor_id    :   res_min_it_->actors_ids_ )
        {
            auto    const   &   sub_tree_it     =   get_sub_tree_it( actor_id );
 
            if  (
                    sub_tree_it     !=  sub_trees_.end()
                )
            {
                ( *sub_tree_it )->print_id_and_id_of_price_min_actors();
            }
        }//for
    }
    //-------------------------------------------------------------------------
    T_off_trees::const_iterator   get_sub_tree_it( T_id   id )              const
    {
        return  std::find_if
                    (
                        sub_trees_.begin    (),
                        sub_trees_.end      (),
 
                        [=]                 (
                                                auto    const   &   sub_tree
                                            )
                        {
                            return  sub_tree->id_   ==  id;
                        }
                    );
    }
    //-------------------------------------------------------------------------
};
///////////////////////////////////////////////////////////////////////////////
int     main()
{
    T_off_tree  off_tree_1  =   new     T_official
                                            (
                                                1,
                                                {
                                                    { 10,   {2, 3}  },
                                                    { 20,   {3, 4}  }
                                                }
                                            );
 
    T_off_tree  off_tree_2  =   new     T_official
                                            (
                                                2,
                                                {
                                                    { 30,   {}  }
                                                }
                                            );
 
 
    T_off_tree  off_tree_3  =   new     T_official
                                            (
                                                3,
                                                {
                                                    { 40,   {5}     },
                                                    { 50,   {5, 6}  }
                                                }
                                            );
 
    T_off_tree  off_tree_4  =   new     T_official
                                            (
                                                4,
                                                {
                                                    { 50,   {}  }
                                                }
                                            );
 
    T_off_tree  off_tree_5  =   new     T_official
                                            (
                                                5,
                                                {
                                                    { 60,   {}  }
                                                }
                                            );
 
    T_off_tree  off_tree_6  =   new     T_official
                                            (
                                                6,
                                                {
                                                    { 70,   {}  }
                                                }
                                            );
 
    off_tree_3->add_sub( off_tree_5 );
    off_tree_3->add_sub( off_tree_6 );
 
    off_tree_1->add_sub( off_tree_2 );
    off_tree_1->add_sub( off_tree_3 );
    off_tree_1->add_sub( off_tree_4 );
 
    off_tree_1->print_price_min_and_id_of_actors_of_price_min();
}
Сама ошибка:
124 81 C:\Users\Alesha\Desktop\Áåçûìÿííûé1.cpp [Error] parameter declared 'auto'
То ли я дурак, то ли лыжи не едут
0
Programming
Эксперт
94731 / 64177 / 26122
Регистрация: 12.04.2006
Сообщений: 116,782
23.10.2016, 20:16
Ответы с готовыми решениями:

Ошибка: ‘cluster’ was not declared in this scope
Допустим (какой-то пример): class test { public: void foo() { ...

Ошибка missing default parameter for parameter
вот программка #include &lt;iostream&gt; #include &lt;conio.h&gt; using namespace std; int n,i,d; ...

Ошибка '. has not been declared'
Доброго времени суток! Получаю ошибку во время сборки: In file included from...

was not declared ошибка
в кодах очень плох, и только начал, объясните в чем ошибка и как ее решить, пожалуйста #include...

4
Эксперт С++
4985 / 3092 / 456
Регистрация: 10.11.2010
Сообщений: 11,169
Записей в блоге: 10
24.10.2016, 07:17 2
Включи стандарт C++11.
0
0 / 0 / 0
Регистрация: 30.10.2014
Сообщений: 22
24.10.2016, 15:42  [ТС] 3
В том-то и дело, что он включен
0
277 / 226 / 93
Регистрация: 27.06.2016
Сообщений: 639
24.10.2016, 18:16 4
FirstDeath, а 14й?
0
Вездепух
Эксперт CЭксперт С++
11695 / 6374 / 1724
Регистрация: 18.10.2014
Сообщений: 16,068
24.10.2016, 21:56 5
Цитата Сообщение от FirstDeath Посмотреть сообщение
В том-то и дело, что он включен
Для auto параметров нужен C++14.
0
24.10.2016, 21:56
IT_Exp
Эксперт
87844 / 49110 / 22898
Регистрация: 17.06.2006
Сообщений: 92,604
24.10.2016, 21:56
Помогаю со студенческими работами здесь

Ошибка 'N' was not declared in this scope
#include &lt;iostream&gt; using namespace std; int N int vvod(int N,int A,int I) { ...

Ошибка was not declared in this scope
Как мне её исправить polimorfizm1881.cpp: In function ‘int main()’: polimorfizm1881.cpp:38:29:...

Ошибка was not declared in this scope
main. cpp #include &quot;PoolAllocator.h&quot; ... reqs.addr = Allocate(reqs.bytes, 10); ...

Ошибка 'Randomize' was not declared in this scope
Сегодня - первый день, когда я что-то &quot;создаю&quot; на языке с++, поэтому я с ним на &quot;Вы&quot;. Собственно,...


Искать еще темы с ответами

Или воспользуйтесь поиском по форуму:
5
Ответ Создать тему
КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin
Copyright ©2000 - 2024, CyberForum.ru