473,396 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

error: expected initializer before <type>

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

$

Jun 27 '08 #1
1 10185
On May 15, 4:50*pm, "lovecreatesbea...@gmail.com"
<lovecreatesbea...@gmail.comwrote:
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 &'.
[...]
//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)
my bad, I forgot one semicolon at the end of the declaration.

I have another question, why the macros can not have the same names
with other identifiers? The macro names and the identifiers are in
different namespace (C's), right? The typedef names can be the same
as, for example, the structure names, right?
Jun 27 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Steve Wilkinson | last post by:
I've just started using managed C++ with VS2005, so please forgive my ignorance. I'm investigating producing a managed wrapper for some functionality of the Windows Media Format SDK. I have the...
8
by: Rainer Queck | last post by:
Hi NG, I have a base class "Telegram". This class , as well as all descants have a static public field "public static int TelegramNo = <a tlg no>;" Now I added all descants of Telegram to a...
8
by: Taras_96 | last post by:
Hi everyone, We' ve come to the conclusion that we wish the user to be directed to an error page if javascript is disabled <enter comment about how a webpage shouldn't rely on javascript here :)...
1
by: =?Utf-8?B?RnJhbmNvaXNWaWxqb2Vu?= | last post by:
Hi there, Does anybody know how to return the results of an IEnumerable<typeas an array of the same type i.e type in a web service call without first having to collect all elements in the...
8
by: =?Utf-8?B?V2hpdG5leSBLZXc=?= | last post by:
Hi there, I'm having a bit of trouble using an HRASCONN object as a class member variable inside my managed C++ class. When I call RasDial() and pass in the address of my HRASCONN object, I get...
3
by: Dylan Nicholson | last post by:
Can someone confirm that a) is illegal, and b) the solution? a) namespace Test { struct MyStruct { int a; int b;
5
by: Ronald S. Cook | last post by:
From my business tier (class) I get back an IQueryable<Penof data. Here is my client code that works fine: PenClass penClass = new PenClass(); IQueryable<Penpens = penClass.SelectPens(); ...
6
by: A.Rocha | last post by:
Hi, I need save to text file a List<type>, but i dont wont serialize. // List<mytypemyList = new List<mytype>(); anyone can help me? --
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.