Lex0R 0 / 0 / 0 Регистрация: 28.03.2013 Сообщений: 5 |
||||
1 |
||||
10.06.2013, 19:08. Показов 23846. Ответов 4 Метки нет (Все метки)
Добрый день, пытаюсь освоить списки, пока почти ничего ещё не понял. Вообщем собираюсь сделать несколько элементов списка, так же поиск и удаление элементов, до удаления ещё не дошёл.
__________________
0 |
Croessmah Don’t worry, be happy 17781 / 10545 / 2036 Регистрация: 27.09.2012 Сообщений: 26,516 Записей в блоге: 1 |
||||
10.06.2013, 19:20 |
2 |
|||
1 |
Lex0R 0 / 0 / 0 Регистрация: 28.03.2013 Сообщений: 5 |
||||
10.06.2013, 19:23 [ТС] |
3 |
|||
Тьфу ты блин, я уже минут 20 сижу эти скобки считаю, проглядел. Спасибо большое. Ещё вопрос можно?
0 |
Don’t worry, be happy 17781 / 10545 / 2036 Регистрация: 27.09.2012 Сообщений: 26,516 Записей в блоге: 1 |
|
10.06.2013, 19:29 |
4 |
Можете почитать книгу Уильям Топп, Уильям Форд «Структуры данных в C++»
1 |
0 / 0 / 0 Регистрация: 28.03.2013 Сообщений: 5 |
|
10.06.2013, 19:38 [ТС] |
5 |
Можете почитать книгу Уильям Топп, Уильям Форд «Структуры данных в C++» Благодарю за помощь.
0 |
Expected declaration before token ‘}’
HI all
Please help with this problem. I think its quite small and I have been looking at it for ages but cant work it out?? The error I get in the code is as per the title of this message and it appears in line 13:1, at the end of the first function. It is a compile time error. I think its to do with brackets but I have tried as many combinations as I can think of with no success. The code is below. If anyone can help me out I would be grateful.
#include <iostream>
#include <vector>
using namespace std;
template<typename T>
void Print(T array[], int array_size)
{
for(int i = 0; i < array_size; i++)
cout <<array[i] <<» «;
}
}
template<typename T>
void print2(T vector<int> & v)
{
for (int i=1; i<=v.size(); i++) v.push_back(i);
{
std::cout << «myvector contains:»;
for (std::vector<int>::const iterator it = v.begin() ; it != v.end(); ++it){
std::cout << ‘ ‘ << *it;
std::cout << ‘n’;
}
}
}
int main (){
//double Array[10] = {1.3,2.44,0,3,4,2,5,6,0,7};
//Print(Array, 10);
string s[] = {«if», «you»,»just»,»think»,»about»,»it»,»it’s»,»actually»,»quite», «easy»};
Print(s, 10);
//int vector[3] = {1,2,3};
//print2(vector);
}
Remove the bracket on line 13.
if you indent your code, you will quickly see where is the brace error :
( and remove std:: prefixes since, you have using namespace std;
)
|
|
Hi Fran
Thanks for the prompt reply.
I have tried this previously and this then brings up three more errors relating to line 15:27.
expected unqualified id before & token
expected ) before & token
expected initializer before & token.
Any ideas?
Hi Shadow fiend,
I removed a bracket from the original code but it brought up the three errors I listed to you. Im very new to this C++ so I cant work it out? When I add the backet I get one error when I take it out I get three? Also, if I want to use the std:: prefix do I put using std::cout and std::vector at the top instead of using namespace std?
Hi bennyscammin1
There are a few problems with the code,
#include <iostream>
#include <vector>
using namespace std;
template<typename T>
void Print(T array[], int array_size)
{
for(int i = 0; i < array_size; i++)
cout <<array[i] <<» «;
}
template<typename T>
void print2(const vector<T>& v)
{
for (int i=1; i<=v.size(); i++) v.push_back(i);
{
cout << «myvector contains:»;
for (const::vector<int>::iterator it = v.begin() ; it != v.end(); ++it)
{
cout << ‘ ‘ << *it;
cout << ‘n’;
}
}
}
int main ()
{
//double Array[10] = {1.3,2.44,0,3,4,2,5,6,0,7};
//Print(Array, 10);
string s[] = {«if», «you»,»just»,»think»,»about»,»it»,»it’s»,»actually»,»quite», «easy»};
Print(s, 10);
system («pause»);
//int vector[3] = {1,2,3};
//print2(vector);
}
Its always good to use using namespace std because by using that only you will be free to use std:: at every required place in your program.
That will not only reduce size of the program but also helps you to make any mistake related to std::
No Joy with that. Its now throwing up a full page of errors? Did the code above compile for you?
Thanks
Thanks. I will look into it further. There must be some issue with my compiler.
Topic archived. No new replies allowed.
In first compile with the librari :
expected declaration before ‘}’ token in the esp32ModbusTypeDefs.h line 66.
I can’t see where this error comes from…
How does your file compare to the file in this repo?
Are there any more error messages?
Remark: I had some problems with this lib and am rewriting completely from scratch.
Iam using the Example code from github. I dont write anything else yet.
Just included the lib header and copy paste the rest just to see if it is
compile or not. But it is not.
I wanted to communicate with a PLC via modbus with this lib.
Bert Melis <notifications@github.com> ezt írta (időpont: 2019. aug. 14.,
Sze 9:20):
…
I can’t see where this error comes from…
How does your file compare to the file in this repo?
Are there any more error messages?
Remark: I had some problems with this lib and am rewriting completely from
scratch.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#6?email_source=notifications&email_token=AJBE42IFUKBNKPNQZMN66ZDQEOW5LA5CNFSM4ILRYHPKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4H5TBQ#issuecomment-521132422>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AJBE42KVJYKKCNUUT7HGVADQEOW5LANCNFSM4ILRYHPA>
.
Yes, i have got some more errors but i think all of it are related to this error.
Other error messages are two include errors. the stdint.h and the functional.
I don’t know why these are here. I’am using PlatformIO ide with vscode and latest esp32 core in it with latest async lib.
You mean you cannot include stdint and functional? Well, if these things are not included, the file will not compile.
Surprising however because these files belong to the Arduino core and should be available when installign through Platformio.
They are included just the platformIO can not open them for some reason. I use my own library folder inside my project. Every library is in that folder. And some of them are using these libs too without a problem. :/
12 Years Ago
Hi,
please help me with error.
I want to run simple project below.
I have a lot of errors below and don’t know how to fix it.
I use GCC port (Mingw)
#include "mysql/my_global.h"
#include "mysql/mysql.h"
#include <stdio.h>
int main(int argc, char **argv)
{
printf("MySQL client version: %sn", mysql_get_client_info());
}
error
———-Build Started———
C:WINDOWSsystem32cmd.exe /c «»mingw32-make.exe» -j 2 -f «learn MySQL_wsp.mk»»
———-Building project:[ basics — Debug ]———-
mingw32-make.exe[1]: Entering directory `C:/Documents and Settings/stefano/Desktop/C++/learn MySQL’
gcc -c «C:/Documents and Settings/stefano/Desktop/C++/learn MySQL/main.c» -g -DSTACK_DIRECTION=1 -o ./Debug/main.o «-I.» «-I.» «-I./mysql»
In file included from C:/Documents and Settings/stefano/Desktop/C++/learn MySQL/mysql/my_global.h:76,
from C:/Documents and Settings/stefano/Desktop/C++/learn MySQL/main.c:1:
./mysql/config-win.h:203:1: warning: «finite» redefined
./mysql/config-win.h:161:1: warning: this is the location of the previous definition
./mysql/config-win.h:245:1: warning: «STACK_DIRECTION» redefined
<command-line>: warning: this is the location of the previous definition
In file included from C:/Documents and Settings/stefano/Desktop/C++/learn MySQL/mysql/my_global.h:415,
from C:/Documents and Settings/stefano/Desktop/C++/learn MySQL/main.c:1:
c:mingw-4.4.1bin../lib/gcc/mingw32/4.4.1/../../../../include/stdio.h:491: error: expected declaration specifiers or ‘…’ before ‘(‘ token
c:mingw-4.4.1bin../lib/gcc/mingw32/4.4.1/../../../../include/stdio.h:491: error: expected declaration specifiers or ‘…’ before ‘(‘ token
In file included from C:/Documents and Settings/stefano/Desktop/C++/learn MySQL/main.c:1:
C:/Documents and Settings/stefano/Desktop/C++/learn MySQL/mysql/my_global.h:616:1: warning: «my_reinterpret_cast» redefined
In file included from C:/Documents and Settings/stefano/Desktop/C++/learn MySQL/mysql/my_global.h:76,
from C:/Documents and Settings/stefano/Desktop/C++/learn MySQL/main.c:1:
./mysql/config-win.h:307:1: warning: this is the location of the previous definition
In file included from C:/Documents and Settings/stefano/Desktop/C++/learn MySQL/main.c:1:
C:/Documents and Settings/stefano/Desktop/C++/learn MySQL/mysql/my_global.h:1566: error: static declaration of ‘rint’ follows non-static declaration
mingw32-make.exe[1]: *** [Debug/main.o] Error 1
mingw32-make.exe[1]: Leaving directory `C:/Documents and Settings/stefano/Desktop/C++/learn MySQL’
mingw32-make.exe: *** [All] Error 2
———-Build Ended———-
5 errors, 5 warnings
Edited
12 Years Ago
by Stefano Mtangoo because:
n/a