473,394 Members | 1,701 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,394 software developers and data experts.

string merge

why the following code not compile

================
#include <iostream>
using std::cout; // must need for using cout
using std::endl;

#include <string>
using std::string;

int main()
{
string stringa("abc");
string stringb("bbb");
cout << merge (stringa, stringb);
} // end main

string merge ( string a, string b){
string c = a + b;
return c;
}
Apr 3 '08 #1
2 6018

"Carmen Sei" <fa**********@yahoo.comwrote in message why the following
code not compile
>
================
#include <iostream>
using std::cout; // must need for using cout
using std::endl;

#include <string>
using std::string;

int main()
{
string stringa("abc");
string stringb("bbb");
cout << merge (stringa, stringb);
} // end main

string merge ( string a, string b){
string c = a + b;
return c;
}
Compiler needs to know the signature/prototype of the functions that it
comes across while compiling. We generally include header files for this
purpose, like <stdio.hfor printf. In your case compiler doesn't know about
the merge function, when it encounters it in main. So add the function
prototype of merge before main, or move the definition before main.

Sharad
Apr 4 '08 #2
Sharad wrote:
>
Compiler needs to know the signature/prototype of the functions that it
comes across while compiling.
In C++ the word you are looking for is "declaration".
Prototype is a C term.

Signature is something else.
Apr 4 '08 #3

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

Similar topics

8
by: Michele Simionato | last post by:
I was playing with string.Template in Python 2.4 and I came out with the following recipe: import sys from string import Template def merge(*dictionaries): """Merge from right (i.e. the...
8
by: Squirrel | last post by:
Hi everyone, I've created a mail merge Word doc. (using Office XP) , the data source is an Access query. Functionality I'm attempting to set up is: User sets a boolean field to true for...
3
by: Andy Davis | last post by:
I have set up a mail merge document in Word 2003 which gets its data from my Access 2000 database. I want to set up a button on a form that: 1. runs the query to provide the dat for the merge...
3
by: carl.barrett | last post by:
Hi, I have a number of buttons on a form which run mailmerges. Next to each button is a text box/control that the user enters a date into when the letter was created/merged. When the user...
4
by: mrgr8avill | last post by:
Hello, all. First off, I apologize for my ignorance. I am not used to working with non-variants, and it has been a LONG time since I dealt with OOP. I need to pass a string to a compiled...
9
by: zjut | last post by:
I want to add a string to the file and the file is sort by letter! for examply: the follow file is a big file ////////////////////// abort black cabbage dog egg fly
7
by: Sharon | last post by:
I have successfully loaded a DataSet object with a XML schema (XSD). Now I wish to populate the tables that was created in the DataSet. I have an XML file/string that contain all the needed data...
1
by: Joe Fallon | last post by:
I know that String.Format has the ability to format a string using placeholders like {0}, {1}, {2} etc. Is there a way to make a template that uses variables like <% MyVar1 %> instead of {0}?...
4
by: John J. Hughes II | last post by:
Could someone explain how to merge the form menu with the mdi container window. The menu strip items on the form window merge but I either end up with a blank blue menu on the form or top list of...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.