473,396 Members | 1,938 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.

code portability and function call serialisation.

Hello.

I recently discovered that this kind of code :

| struct Object
| {
| string f() { return string("Toto"); }
| }
|
| int main( ... )
| {
| Object o;
|
| cout << o.f().c_str() << endl;
|
| return 0;
| }

Is working fine with SUN's C++ compilers and Visual C++ 6 (compiler)
but not fine at all with AIX ones.

What is the status of this kind of code ( o.f().g().h().j() )

a) Is this part of the C++ standard ?

b) Is this only a features that is supposed by the standard to be
compiler dependent ?

c) Is this an AIX compiler bug ?

I would say the answer is the b) one, but i'm not sure.

What is your point of view about this ?

Regards.

Benoit Lefevre.
Jul 19 '05 #1
1 1820
"Lefevre" <be************@reuters.com> wrote...
Hello.

I recently discovered that this kind of code :

| struct Object
| {
| string f() { return string("Toto"); }
'string' is undefined. Did you forget to include a header,
maybe?
| }
Missing ; here.
|
| int main( ... )
There is no allowed declaration of 'main' that would accept
any number and types of arguments. It's either (void) or
(int, char*[]).
| {
| Object o;
|
| cout << o.f().c_str() << endl;
|
| return 0;
| }

Is working fine with SUN's C++ compilers and Visual C++ 6 (compiler)
but not fine at all with AIX ones.

What is the status of this kind of code ( o.f().g().h().j() )

a) Is this part of the C++ standard ?
Pretty much. If a member function returns an object (or a reference
to an object), another member function can be called using operator.
(operator "dot").

b) Is this only a features that is supposed by the standard to be
compiler dependent ?
Nope. BTW, they have been in the language since the beginning, I
believe.

c) Is this an AIX compiler bug ?
Your code is not compilable. Post the real code, post the compiler
diagnostic messages you're getting, then we could try to determine
whether it's a compiler's fault.

I would say the answer is the b) one, but i'm not sure.
I would say you need to study C++ a bit more.

What is your point of view about this ?


My point of view is that you need to post real code, not something
you just remembered and typed in with tons of errors into a message.

Victor
Jul 19 '05 #2

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

Similar topics

24
by: Tim Tyler | last post by:
I just ported one of the apps I wrote using PHP 5 under Windows to PHP 4 under unix. I knew I wanted to deploy in this environment - and wrote my code in anticipation of running in the other...
8
by: Rico Huijbers | last post by:
Hello, I'd like to know if it's possible to curry a function in PHP? That is, is there some built-in mechanism for it, or is it possible to create a function that does the currying? I've...
45
by: Steven T. Hatton | last post by:
This is a purely *hypothetical* question. That means, it's /pretend/, CP. ;-) If you were forced at gunpoint to put all your code in classes, rather than in namespace scope (obviously classes...
3
by: enfis.the.paladin | last post by:
Hi to all! I have something like this: class FWrap { public: virtual void READ (void) = 0; } class Optimized { private:
8
by: Paul Cochrane | last post by:
Hi all, I've got an application that I'm writing that autogenerates python code which I then execute with exec(). I know that this is not the best way to run things, and I'm not 100% sure as to...
143
by: suri | last post by:
Hello I downloaded glibc and tried looking for the code that implements the sine function i couldnt find the file. i went to the math directory and found math.h.. i guess that needs to be...
14
by: genus_ | last post by:
The below code compiles and runs smoothly. Can any one at least explain to me what its doing for first few lines? Thank you. Here's the code: #include <stdio.h> main(t,_,a) char *a;...
2
by: Greg | last post by:
I have a bizarre situation in which serialisation is failing routinely under a specific condition, and I'm wondering if the details ring a bell with anyone here. I have 2 classes that my...
14
by: anchitgood | last post by:
Hey, I have developed the following code and it is executing well on windows. But I don't have LINUX installed on my system. I would be grateful to you guys if you check whether this code is...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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.