L
lovecreatesbea...
In the following function `HardwareStatusDb()', If its arguments are
declared as type of `string', I get:
main.cpp:5: error: expected initializer before ‘int’.
The error disappears when those arguments are declared as type of
`string &'.
Why am I getting this error?
Thank you for your time.
$ make
g++ -Wall -W -I/usr/include/mysql -I/usr/local/include/mysql++ -c -o
main.o main.cpp
main.cpp:5: error: expected initializer before ‘int’
make: *** [main.o] Error 1
$ cat HardwareStatusDb.cpp
#include <string>
using std::string;
#include "HardwareStatusDb.h"
//bool HardwareStatusDb(const string &database, const string &server,
// const string &username, const string &password, const string
&device)
bool HardwareStatusDb(string database, string server,
string username, string password, string device)
{
return true;
}
$ cat main.cpp
#include <string>
using std::string;
#include "HardwareStatusDb.h"
int main(int argc, char *argv[])
{
string s;
HardwareStatusDb(s, s, s, s, s);
return 0;
}
$ cat HardwareStatusDb.h
#ifndef HardwareStatusDb_h
#define HardwareStatusDb_h
#include <string>
using std::string;
//bool HardwareStatusDb(const string &database, const string &server,
// const string &username, const string &password, const string
&device);
bool HardwareStatusDb(string database, string server,
string username, string password, string device)
#endif
$
declared as type of `string', I get:
main.cpp:5: error: expected initializer before ‘int’.
The error disappears when those arguments are declared as type of
`string &'.
Why am I getting this error?
Thank you for your time.
$ make
g++ -Wall -W -I/usr/include/mysql -I/usr/local/include/mysql++ -c -o
main.o main.cpp
main.cpp:5: error: expected initializer before ‘int’
make: *** [main.o] Error 1
$ cat HardwareStatusDb.cpp
#include <string>
using std::string;
#include "HardwareStatusDb.h"
//bool HardwareStatusDb(const string &database, const string &server,
// const string &username, const string &password, const string
&device)
bool HardwareStatusDb(string database, string server,
string username, string password, string device)
{
return true;
}
$ cat main.cpp
#include <string>
using std::string;
#include "HardwareStatusDb.h"
int main(int argc, char *argv[])
{
string s;
HardwareStatusDb(s, s, s, s, s);
return 0;
}
$ cat HardwareStatusDb.h
#ifndef HardwareStatusDb_h
#define HardwareStatusDb_h
#include <string>
using std::string;
//bool HardwareStatusDb(const string &database, const string &server,
// const string &username, const string &password, const string
&device);
bool HardwareStatusDb(string database, string server,
string username, string password, string device)
#endif
$