473,587 Members | 2,542 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

compiler error: cannot convert type void to string

I call method Foo(string s);

with Foo("foo"+"bar" );

what's the deal here?
Oct 8 '08 #1
6 4432
On Oct 8, 4:20*pm, puzzlecracker <ironsel2...@gm ail.comwrote:
I call method Foo(string s);

with Foo("foo"+"bar" );

what's the deal here?
My guess is that you're doing something like:

string x = Foo("foo" + "bar");

If not, please show a short but complete program which demonstrates
the problem.

Jon
Oct 8 '08 #2
On Oct 8, 11:20 am, puzzlecracker <ironsel2...@gm ail.comwrote:
I call method Foo(string s);

with Foo("foo"+"bar" );

what's the deal here?
post your complete code

I do nt know if you are doing
string s = Foo("foo"+"bar" );
or
Foo( Foo("foo"+"bar" ) );
Oct 8 '08 #3
On Oct 8, 11:20 am, puzzlecracker <ironsel2...@gm ail.comwrote:
I call method Foo(string s);

with Foo("foo"+"bar" );

what's the deal here?
In any case your method is returning void, it should be returning
string
Oct 8 '08 #4
On Oct 8, 11:22*am, "Jon Skeet [C# MVP]" <sk...@pobox.co mwrote:
On Oct 8, 4:20*pm, puzzlecracker <ironsel2...@gm ail.comwrote:
I call method Foo(string s);
with Foo("foo"+"bar" );
what's the deal here?

My guess is that you're doing something like:

string x = Foo("foo" + "bar");

If not, please show a short but complete program which demonstrates
the problem.

Jon
I just call a method, with concatenation of two strings,that takes
string parameter. That's all.

BTW what is wrong with string x = Foo("foo" + "bar"); ?
Oct 8 '08 #5
On Oct 8, 8:43*am, puzzlecracker <ironsel2...@gm ail.comwrote:
On Oct 8, 11:22*am, "Jon Skeet [C# MVP]" <sk...@pobox.co mwrote:
On Oct 8, 4:20*pm, puzzlecracker <ironsel2...@gm ail.comwrote:
I call method Foo(string s);
with Foo("foo"+"bar" );
what's the deal here?
My guess is that you're doing something like:
string x = Foo("foo" + "bar");
If not, please show a short but complete program which demonstrates
the problem.
Jon

I just call a method, *with concatenation of two strings,that takes
string parameter. *That's all.

BTW what is wrong with *string x = Foo("foo" + "bar"); ?
can you please post the signature of method please?

I guess it is

public/private void Foo(string)
-Cnu
Oct 8 '08 #6
On Oct 8, 4:43*pm, puzzlecracker <ironsel2...@gm ail.comwrote:
I just call a method, *with concatenation of two strings,that takes
string parameter. *That's all.
I'm afraid I don't believe you. Please post a short but complete
program that demonstrates the problem.
BTW what is wrong with *string x = Foo("foo" + "bar"); ?
If Foo is declared to be void, then you can't assign a string variable
based on the result, because there isn't one.

Jon
Oct 8 '08 #7

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

Similar topics

19
3542
by: Alf P. Steinbach | last post by:
// As usual the error message directs one to the report the bug. // // And as usual there is absolutely no way to do so without paying for // the privilege... // // Or using three or four hours to find the _current_ reporting page... #include <vector> #include <iostream>
19
2833
by: Canonical Latin | last post by:
"Leor Zolman" <leor@bdsoft.com> wrote > "Canonical Latin" <javaplus@hotmail.com> wrote: > > > ... > >But I'm still curious as to the rational of having type > >pointer-to-array-of-size-N-of-type-T (which is fine) and not having type > >array-of-size-N-of-type-T (with some exceptions, which is curious). > > So far > >the consensus seems to be that while everyone is aware of this no one knows
2
1677
by: George Bell | last post by:
The compiler(gcc) gives me this error faxGettyApp.c++:596: ANSI C++ forbids implicit conversion from `void *' in assignment make: *** Error 1 on this code void faxGettyApp::setEnvVar(char* var, char* val)
13
1854
by: Neil Zanella | last post by:
Hello, I wonder whether anyone has ever come across the following g++ compiler error message. I don't recall ever seeing it before. I solved my problem but I am still not sure about what this message is all about. Any ideas? error: invalid initialization of non-const reference of
4
1947
by: KK | last post by:
Hello all, I have class 'atr' which is based on templates. My idea was to initialize it two scenarios 1. std::string case 2. other data types I have defined the Init for the above different cases accordingly (code shown below). However, I get compiler error. Please help me resolve it. Thanks.
1
4118
by: keithb | last post by:
This application works without error in the development environment using the VS web server. When I publish the site to my IIS 6.0 server, I get this error at runtime when I open the Change Password page: Compiler Error Message: CS0030: Cannot convert type 'ASP.admin_changepassword_aspx' to 'System.Web.UI.WebControls.ChangePassword' Compiler Error Message: CS0030: Cannot convert type
3
3401
by: maya | last post by:
am following "asp.NET Unleashed", by Stephen Walther (a SAMS book.. covers .net 1.1 though..) on one of his examples (ch 2) am getting compilation error.. code: <script Runat="Server"> void ChangeBox1( object s, EventArgs e ) { txtBox1 = StrReverse( txtBox1 ); CheckWin(); }
13
1523
by: murphman | last post by:
I recently decided to do the right thing & write accessor functions for my class member variables instead of having them public and introduced a rather nasty bug. The class below shows the error - basically if you forget to add the parenthesis in the call to function X() then the program compiles ok with no warnings but gives the wrong answer :( I'm using VS2005 Prof edition v2.0.50727 The answer seems to be that if you are writing...
0
2044
by: erik.erikson | last post by:
I am getting a compiler error that I can't well explain or even understand the origin of (though I boiled it down close...). Below is a bare-bones example. What I am doing is defining the increment operator in a class and then defining a derived class and using the derived class. When I try to use the increment operator on an instance of the derived class (as an instance of the derived class, not when used as an instance of the base...
0
7857
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8220
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
8352
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...
1
7981
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8222
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...
0
3882
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2367
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
1
1457
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1194
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.