Why can't a function not return string? (error: new types may not be
defined in a return type)...
How can i solve it?
I thought of passing the string into the function, but that will make
me redesign most of the app and i want to avoid it.. is there any other
way to overcome this?
tia, streamkid 17 6185 st*******@gmail.com napsal:
Why can't a function not return string? (error: new types may not be
defined in a return type)...
How can i solve it?
I thought of passing the string into the function, but that will make
me redesign most of the app and i want to avoid it.. is there any other
way to overcome this?
tia, streamkid
You wrote here no code, so it is very hard to think, where is your
problem. But there is definitely possible to return strings:
#include <string>
std::string RetString()
{
return "Hello";
}
If you mean returning C-strings, it works too:
const char* RetCString()
{
return "Hello";
} st*******@gmail.com wrote:
Why can't a function not return string? (error: new types may not be
defined in a return type)...
How can i solve it?
I thought of passing the string into the function, but that will make
me redesign most of the app and i want to avoid it.. is there any other
way to overcome this?
tia, streamkid
Please paste a snippet of your code. There is nothing stopping you
from returning a class or a C style string.
Also, please post what compiler and OS you are compiling this on.
Ï/Ç Ondra Holub Ýãñáøå:
st*******@gmail.com napsal:
Why can't a function not return string? (error: new types may not be
defined in a return type)...
How can i solve it?
I thought of passing the string into the function, but that will make
me redesign most of the app and i want to avoid it.. is there any other
way to overcome this?
tia, streamkid
You wrote here no code, so it is very hard to think, where is your
problem. But there is definitely possible to return strings:
#include <string>
std::string RetString()
{
return "Hello";
}
If you mean returning C-strings, it works too:
const char* RetCString()
{
return "Hello";
}
thanks for the quick answer :)
well i tried this and it works :s
BUT
i have
class a
{
public:
string getit();
private:
string astring;
}
i try to compile it and is says the error mentioned above... st*******@gmail.com wrote:
Why can't a function not return string? (error: new types may not be
defined in a return type)...
How can i solve it?
Without code, I can only guess that you have forgotten to qualify
'string' with 'std::'.
--
Ian Collins.
Ï/Ç Signal9 Ýãñáøå:
st*******@gmail.com wrote:
Why can't a function not return string? (error: new types may not be
defined in a return type)...
How can i solve it?
I thought of passing the string into the function, but that will make
me redesign most of the app and i want to avoid it.. is there any other
way to overcome this?
tia, streamkid
Please paste a snippet of your code. There is nothing stopping you
from returning a class or a C style string.
Also, please post what compiler and OS you are compiling this on.
i tried on slackware using g++
and on vista using devcpp st*******@gmail.com wrote:
>
well i tried this and it works :s
BUT
i have
class a
{
public:
string getit();
Looks like I made the correct guess.
--
Ian Collins. st*******@gmail.com napsal:
Why can't a function not return string? (error: new types may not be
defined in a return type)...
How can i solve it?
I thought of passing the string into the function, but that will make
me redesign most of the app and i want to avoid it.. is there any other
way to overcome this?
tia, streamkid
I think you have defined class without semicolon at the end. Something
like this:
class A
{
} // Here is missing semicolon
int main()
{
}
to both Ondra Holub:
i 've forgot the semicolon only here..
Ian Collins:
no unfortunatelly you haven't. that's not the prob.. i wish it was.. st*******@gmail.com wrote:
to both Ondra Holub:
i 've forgot the semicolon only here..
Ian Collins:
no unfortunatelly you haven't. that's not the prob.. i wish it was..
I haven't what? Please provide context.
--
Ian Collins. st*******@gmail.com wrote:
<snip>
>
thanks for the quick answer :)
well i tried this and it works :s
BUT
i have
class a
{
public:
string getit();
private:
string astring;
}
i try to compile it and is says the error mentioned above...
There is no way you'll get that to compile.
There is no such thing as a string, a std::string maybe and thats only
if you #include <string>.
A class declaration requires a semi-colon.
Any member function you declare needs to be implemented if you plan to
use it.
Ï/Ç Salt_Peter Ýãñáøå:
st*******@gmail.com wrote:
<snip>
thanks for the quick answer :)
well i tried this and it works :s
BUT
i have
class a
{
public:
string getit();
private:
string astring;
}
i try to compile it and is says the error mentioned above...
There is no way you'll get that to compile.
There is no such thing as a string, a std::string maybe and thats only
if you #include <string>.
A class declaration requires a semi-colon.
Any member function you declare needs to be implemented if you plan to
use it.
well that's not the code!!!!!!!!!!!!!!!!!!!!
i just wrote this to show sth _like_ that i've written and i'm trying
to compile!
ofc i'm not trying to compile this! st*******@gmail.com wrote:
>
well that's not the code!!!!!!!!!!!!!!!!!!!!
i just wrote this to show sth _like_ that i've written and i'm trying
to compile!
ofc i'm not trying to compile this!
One of the golden rules (and FAQs) for this (and most other language
groups) is "post a compilable example that demonstrates your problem"
--
Ian Collins. st*******@gmail.com wrote:
>
?/? Salt_Peter ??????:
>st*******@gmail.com wrote: <snip>
>
thanks for the quick answer :)
well i tried this and it works :s
BUT
i have
class a
{
public:
string getit();
private:
string astring;
}
i try to compile it and is says the error mentioned above...
There is no way you'll get that to compile. There is no such thing as a string, a std::string maybe and thats only if you #include <string>. A class declaration requires a semi-colon. Any member function you declare needs to be implemented if you plan to use it.
well that's not the code!!!!!!!!!!!!!!!!!!!!
Well, then post the code.
i just wrote this to show sth _like_ that i've written and i'm trying
to compile!
Please understand that we cannot see what you have on your screen; we only
see what you post here. If that has errors, we point them out. If those
errors are not the ones you are interested in, don't put them in your posts
in the first place.
ofc i'm not trying to compile this!
See FAQ 5.8.
Best
Kai-Uwe Bux st*******@gmail.com wrote:
Ï/Ç Salt_Peter Ýãñáøå:
st*******@gmail.com wrote:
<snip>
>
thanks for the quick answer :)
>
well i tried this and it works :s
BUT
i have
class a
{
public:
string getit();
private:
string astring;
}
>
i try to compile it and is says the error mentioned above...
There is no way you'll get that to compile.
There is no such thing as a string, a std::string maybe and thats only
if you #include <string>.
A class declaration requires a semi-colon.
Any member function you declare needs to be implemented if you plan to
use it.
well that's not the code!!!!!!!!!!!!!!!!!!!!
i just wrote this to show sth _like_ that i've written and i'm trying
to compile!
ofc i'm not trying to compile this!
Yes it is code. Until proven otherwise, that is.
If you show us code then ... it IS code.
And that WILL NOT COMPILE.
>
You wrote here no code, so it is very hard to think, where is your
problem. But there is definitely possible to return strings:
#include <string>
std::string RetString()
{
return "Hello";
}
If you mean returning C-strings, it works too:
const char* RetCString()
{
return "Hello";
}
HEYY!!!! where were you when i was shouting myself hoarse about the
same topic. you could have solved my problem a millenium ago....
<st*******@gmail.comwrote in message
news:11**********************@16g2000cwy.googlegro ups.com...
Ï/Ç Signal9 Ýãñáøå:
st*******@gmail.com wrote:
Why can't a function not return string? (error: new types may not be
defined in a return type)...
How can i solve it?
I thought of passing the string into the function, but that will make
me redesign most of the app and i want to avoid it.. is there any other
way to overcome this?
tia, streamkid
Please paste a snippet of your code. There is nothing stopping you
from returning a class or a C style string.
Also, please post what compiler and OS you are compiling this on.
i tried on slackware using g++
and on vista using devcpp
Okay, please listen closly.
Post WHAT YOU TRIED TO COMPILE THAT DIDN'T COMPILE.
Other than that, the error is in your program on line 42. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Derek Hart |
last post by:
I wish to execute code from a string. The string will have a function name,
which will return a string:
Dim a as string
a = "MyFunctionName(param1, param2)"
I have seen a ton of people...
|
by: Johno |
last post by:
I have written the two associated base classes below (Digital_camera and
Review) to manage digital camera and review objects. They are base classes
for which other derived classes can be written to...
|
by: Saeed Amrollahi |
last post by:
Dear All C++ Programmers
Hello
I am Saeed Amrollahi. I am a software engineer in
Tehran Sewerage Company. I try to use std::map and map::find member
function. I
use Visual Studio .NET. my...
|
by: pangel83 |
last post by:
I've been trying for days to write a piece of VB.NET code that will
read from winamp's memory space the paths of the files from the current
winamp playlist.
The GETPLAYLISTFILE command of the...
|
by: Paul |
last post by:
Anyone have code that emulates the Nz function in Microsoft Access?
In Access it is:
Nz(Value as variant, Optional ValueIfNull as Variant) as Variant
|
by: karthi |
last post by:
hi,
I need user defined function that converts string to float in c.
since the library function atof and strtod occupies large space in
my processor memory I can't use it in my code.
regards,...
|
by: _Mario.lat |
last post by:
Hallo,
I have a little question:
In the function session_set_save_handler I can pass the name of function
which deal with session.
In Xoops code I see the use of this function like that:
...
|
by: default |
last post by:
Hello All.
I was looking around for a function like strtok() which would tokenize
on
the complete list of delimiters, rather than tokenize on *any* of the
delimiters
in the group. I ended up...
|
by: Terry |
last post by:
I am getting the following warning for the below function. I understand what
it means but how do I handle a null reference? Then how do I pass the
resulting value?
Regards
Warning 1...
|
by: Andrew Morton |
last post by:
Is it possible to have two function declarations which take the same
parameters but return different types depending on how the function is used?
function f(x) as string
' return a string
end...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
| |