473,802 Members | 2,026 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

error: expected initializer before <type>

In the following function `HardwareStatus Db()', 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 HardwareStatusD b.cpp

#include <string>
using std::string;
#include "HardwareStatus Db.h"

//bool HardwareStatusD b(const string &database, const string &server,
// const string &username, const string &password, const string
&device)
bool HardwareStatusD b(string database, string server,
string username, string password, string device)
{
return true;
}

$ cat main.cpp

#include <string>
using std::string;
#include "HardwareStatus Db.h"

int main(int argc, char *argv[])
{
string s;
HardwareStatusD b(s, s, s, s, s);
return 0;
}

$ cat HardwareStatusD b.h

#ifndef HardwareStatusD b_h
#define HardwareStatusD b_h

#include <string>
using std::string;

//bool HardwareStatusD b(const string &database, const string &server,
// const string &username, const string &password, const string
&device);
bool HardwareStatusD b(string database, string server,
string username, string password, string device)

#endif

$

Jun 27 '08 #1
1 10285
On May 15, 4:50*pm, "lovecreatesbea ...@gmail.com"
<lovecreatesbea ...@gmail.comwr ote:
In the following function `HardwareStatus Db()', 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 HardwareStatusD b(const string &database, const string &server,
// * * *const string &username, const string &password, const string
&device);
bool HardwareStatusD b(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
10972
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 following very simple header and class files: Header File: // CSJ.h
8
5683
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 generic List<Type>: List<Type> tlgList = new List<Type>(); TlgList.Add(typeof(Telegram1));
8
2856
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 :) >. I've read quite a few posts on how to do this, but none meet my need (the two main suggestions was set a jsEnabled variable in a <scriptsection of the HTML and read it in PHP, and the other suggestion was by default loading the non js page,...
1
2984
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 IEnumerable<typeand storing it in memory first? This question is really about optimizing large collections of data returned by web services. If it is possible to loop through the IEnumerable<type> with a "foreach" and somehow start formatting the...
8
6275
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 the following compiler error from Visual C++ 2005: error C2664: 'RasDialW' : cannot convert parameter 6 from 'cli::interior_ptr<Type>' to 'HRASCONN *'
3
1503
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
11157
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(); However, I want to then select a subset of this data from within the client. I tried this: IQueryable<PenpensSubset = from p in pens select p.PenId, p.PenNumber;
6
14577
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
9699
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10538
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10305
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10063
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7598
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5494
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4270
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3792
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2966
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.